pycrossword  0.4
Pure-Python implementation of a crossword puzzle generator and editor
Public Member Functions | Public Attributes | List of all members
pycross.forms.DefLookupDialog Class Reference

Word definition lookup dialog to look up a word in a dictionary and/or Google. More...

Inheritance diagram for pycross.forms.DefLookupDialog:
pycross.forms.BasicDialog

Public Member Functions

def __init__ (self, word='', word_editable=False, lang='', parent=None, flags=QtCore.Qt.WindowFlags())
 Constructor. More...
 
def closeEvent (self, event)
 Before the dialog quits, need to stop all running background threads. More...
 
def showEvent (self, event)
 Retrieve results when the dialog shows. More...
 
def kill_threads (self, dics=True, google=True)
 Stops any or both worker threads. More...
 
def addMainLayout (self)
 Creates the main (central) layout for controls. More...
 
def setlang (self, lang='')
 Sets the language to search in the online services. More...
 
def init (self)
 Initializes controls. More...
 
def update_language (self)
 Sets the selected language. More...
 
def update_dict_engine (self)
 Sets the online dictionary engine depending on the selected language. More...
 
def update_google_engine (self)
 Configures the Google search engine depending on the selected language. More...
 
def add_pages (self)
 Adds the Dictionary and Google pages to the tab widget. More...
 
def on_thread_error (self, thread, err)
 Worker thread error handler. More...
 
def on_dics_load_start (self)
 Fires before the dictionary results are retrieved. More...
 
def on_dics_load_run (self)
 Dictionary thread run event handler: retrieve dictionary results. More...
 
def on_dics_load_finish (self)
 Fires after the dictionary results are retrieved. More...
 
def on_google_load_start (self)
 Fires before the Google results are retrieved. More...
 
def on_google_load_run (self)
 Google thread run event handler: retrieve Google search results. More...
 
def on_google_load_finish (self)
 Fires after the Google results are retrieved. More...
 
def update_content (self, dictionary=True, google=True)
 Fills the search results into the corresponding list and combo boxes. More...
 
def rb_source_toggled (self, toggled)
 Shows the specified page when a radio button is toggled. More...
 
def on_le_word_changed (self, text)
 Sets a new search word and restarts the search. More...
 
def on_combo_lang (self, index)
 When a language combo item is selected. More...
 
def on_combo_dict_homs (self, index)
 When a word homonym is selected in the combo (Dictionary page). More...
 
def on_combo_google (self, index)
 When a Google result is selected in the combo (Google page). More...
 
- Public Member Functions inherited from pycross.forms.BasicDialog
def __init__ (self, geometry=None, title=None, icon=None, parent=None, flags=QtCore.Qt.WindowFlags(), sizepolicy=QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed))
 Constructor. More...
 
def initUI (self, geometry=None, title=None, icon=None)
 Creates the core controls: OK and Cancel buttons and layouts. More...
 
def validate (self)
 Validates user input (reimplemented in child classes). More...
 
def on_btn_OK_clicked (self)
 Fires when the OK button is clicked. More...
 
def on_btn_cancel_clicked (self)
 Fires when the Cancel button is clicked: rejects input and closes window. More...
 

Public Attributes

 word
 
 word_editable
 
 word_def
 
 google_res
 
 dict_engine
 
 google_engine
 
 load_threads
 worker threads to retrieve word definitions from the internet More...
 
 layout_controls
 
 gb_word
 
 layout_gb_word
 
 le_word
 
 combo_lang
 
 gb_sources
 
 layout_gb_sources
 
 rb_dict
 
 rb_google
 
 stacked
 
 lang
 
 page_dict
 
 layout_dict
 
 combo_dict_homs
 
 layout_dict_top
 
 te_dict_defs
 
 l_link_dict
 
 page_google
 
 layout_google
 
 combo_google
 
 layout_google_top
 
 te_google_res
 
 l_link_google
 
- Public Attributes inherited from pycross.forms.BasicDialog
 layout_controls
 QtWidgets.QFormLayout central layout for controls More...
 
 btn_OK
 QtWidgets.QPushButton OK button More...
 
 btn_cancel
 QtWidgets.QPushButton Cancel button More...
 
 layout_bottom
 QtWidgets.QHBoxLayout bottom layout for OK and Cancel buttons More...
 
 layout_main
 QtWidgets.QVBoxLayout window layout More...
 

Detailed Description

Word definition lookup dialog to look up a word in a dictionary and/or Google.

Constructor & Destructor Documentation

◆ __init__()

def pycross.forms.DefLookupDialog.__init__ (   self,
  word = '',
  word_editable = False,
  lang = '',
  parent = None,
  flags = QtCore.Qt.WindowFlags() 
)

Constructor.

Parameters
wordstr the word string to look up
word_editablebool whether the word string can be edited in the dialog (default = False)
langstr short name of the langugage used to look up the word. Can be one of: 'en' (English), 'ru' (Russian), 'fr' (French), 'es' (Spanish), 'de' (German), 'it' (Italian) (see globalvars::LANG). If the value is an empty string (default), the setting from guisettings::CWSettings::settings['lookup']['default_lang'] is taken.
parentQtWidgets.QWidget parent widget (default = None, i.e. no parent)
flagsQtCore.Qt.WindowFlags Qt window flags

Member Function Documentation

◆ add_pages()

def pycross.forms.DefLookupDialog.add_pages (   self)

Adds the Dictionary and Google pages to the tab widget.

◆ addMainLayout()

def pycross.forms.DefLookupDialog.addMainLayout (   self)

Creates the main (central) layout for controls.

Must be overridden by child classes to change the layout type (default = QtWidgets.QFormLayout) and add controls.

Reimplemented from pycross.forms.BasicDialog.

◆ closeEvent()

def pycross.forms.DefLookupDialog.closeEvent (   self,
  event 
)

Before the dialog quits, need to stop all running background threads.

◆ init()

def pycross.forms.DefLookupDialog.init (   self)

Initializes controls.

◆ kill_threads()

def pycross.forms.DefLookupDialog.kill_threads (   self,
  dics = True,
  google = True 
)

Stops any or both worker threads.

Parameters
dicsbool stop the dictionary thread (default = True)
googlebool stop the google thread (default = True)

◆ on_combo_dict_homs()

def pycross.forms.DefLookupDialog.on_combo_dict_homs (   self,
  index 
)

When a word homonym is selected in the combo (Dictionary page).

◆ on_combo_google()

def pycross.forms.DefLookupDialog.on_combo_google (   self,
  index 
)

When a Google result is selected in the combo (Google page).

◆ on_combo_lang()

def pycross.forms.DefLookupDialog.on_combo_lang (   self,
  index 
)

When a language combo item is selected.

◆ on_dics_load_finish()

def pycross.forms.DefLookupDialog.on_dics_load_finish (   self)

Fires after the dictionary results are retrieved.

◆ on_dics_load_run()

def pycross.forms.DefLookupDialog.on_dics_load_run (   self)

Dictionary thread run event handler: retrieve dictionary results.

◆ on_dics_load_start()

def pycross.forms.DefLookupDialog.on_dics_load_start (   self)

Fires before the dictionary results are retrieved.

◆ on_google_load_finish()

def pycross.forms.DefLookupDialog.on_google_load_finish (   self)

Fires after the Google results are retrieved.

◆ on_google_load_run()

def pycross.forms.DefLookupDialog.on_google_load_run (   self)

Google thread run event handler: retrieve Google search results.

◆ on_google_load_start()

def pycross.forms.DefLookupDialog.on_google_load_start (   self)

Fires before the Google results are retrieved.

◆ on_le_word_changed()

def pycross.forms.DefLookupDialog.on_le_word_changed (   self,
  text 
)

Sets a new search word and restarts the search.

◆ on_thread_error()

def pycross.forms.DefLookupDialog.on_thread_error (   self,
  thread,
  err 
)

Worker thread error handler.

Parameters
threadutils::QThreadStump worker thread instance
errstr error message

◆ rb_source_toggled()

def pycross.forms.DefLookupDialog.rb_source_toggled (   self,
  toggled 
)

Shows the specified page when a radio button is toggled.

◆ setlang()

def pycross.forms.DefLookupDialog.setlang (   self,
  lang = '' 
)

Sets the language to search in the online services.

Parameters
langstr search result language (see constructor for details of options)

◆ showEvent()

def pycross.forms.DefLookupDialog.showEvent (   self,
  event 
)

Retrieve results when the dialog shows.

◆ update_content()

def pycross.forms.DefLookupDialog.update_content (   self,
  dictionary = True,
  google = True 
)

Fills the search results into the corresponding list and combo boxes.

Parameters
dictionarybool whether to update the dictionary results
googlebool whether to update the Google results

◆ update_dict_engine()

def pycross.forms.DefLookupDialog.update_dict_engine (   self)

Sets the online dictionary engine depending on the selected language.

If the language is English ('en'), the Merriam-Webster dictionary will be used; otherwise, the Yandex dictionary will be used.

See also
utils::onlineservices::MWDict, utils::onlineservices::YandexDict

◆ update_google_engine()

def pycross.forms.DefLookupDialog.update_google_engine (   self)

Configures the Google search engine depending on the selected language.

See also
utils::onlineservices::GoogleSearch

◆ update_language()

def pycross.forms.DefLookupDialog.update_language (   self)

Sets the selected language.

Member Data Documentation

◆ combo_dict_homs

pycross.forms.DefLookupDialog.combo_dict_homs

◆ combo_google

pycross.forms.DefLookupDialog.combo_google

◆ combo_lang

pycross.forms.DefLookupDialog.combo_lang

◆ dict_engine

pycross.forms.DefLookupDialog.dict_engine

◆ gb_sources

pycross.forms.DefLookupDialog.gb_sources

◆ gb_word

pycross.forms.DefLookupDialog.gb_word

◆ google_engine

pycross.forms.DefLookupDialog.google_engine

◆ google_res

pycross.forms.DefLookupDialog.google_res

◆ l_link_dict

pycross.forms.DefLookupDialog.l_link_dict

◆ l_link_google

pycross.forms.DefLookupDialog.l_link_google

◆ lang

pycross.forms.DefLookupDialog.lang

◆ layout_controls

pycross.forms.DefLookupDialog.layout_controls

◆ layout_dict

pycross.forms.DefLookupDialog.layout_dict

◆ layout_dict_top

pycross.forms.DefLookupDialog.layout_dict_top

◆ layout_gb_sources

pycross.forms.DefLookupDialog.layout_gb_sources

◆ layout_gb_word

pycross.forms.DefLookupDialog.layout_gb_word

◆ layout_google

pycross.forms.DefLookupDialog.layout_google

◆ layout_google_top

pycross.forms.DefLookupDialog.layout_google_top

◆ le_word

pycross.forms.DefLookupDialog.le_word

◆ load_threads

pycross.forms.DefLookupDialog.load_threads

worker threads to retrieve word definitions from the internet

◆ page_dict

pycross.forms.DefLookupDialog.page_dict

◆ page_google

pycross.forms.DefLookupDialog.page_google

◆ rb_dict

pycross.forms.DefLookupDialog.rb_dict

◆ rb_google

pycross.forms.DefLookupDialog.rb_google

◆ stacked

pycross.forms.DefLookupDialog.stacked

◆ te_dict_defs

pycross.forms.DefLookupDialog.te_dict_defs

◆ te_google_res

pycross.forms.DefLookupDialog.te_google_res

◆ word

pycross.forms.DefLookupDialog.word

◆ word_def

pycross.forms.DefLookupDialog.word_def

◆ word_editable

pycross.forms.DefLookupDialog.word_editable

The documentation for this class was generated from the following file: