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

Word source editor dialog: provides adding and editing word sources. More...

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

Public Member Functions

def __init__ (self, src=None, parent=None, flags=QtCore.Qt.WindowFlags())
 Constructor. More...
 
def addMainLayout (self)
 Creates the main (central) layout for controls. More...
 
def add_pages (self)
 Creates tabs for the 3 source types. More...
 
def from_src (self, src)
 Initializes controls from word source data. More...
 
def to_src (self)
 Saves current control values to word source data dictionary (WordSrcDialog::src). More...
 
def validate (self)
 Performs various checks of current control values. More...
 
def rb_toggled (self, toggled)
 Fires when WordSrcDialog::rb_type_db is toggled on or off. More...
 
def on_btn_dbedit (self)
 Fired when WordSrcDialog::btn_dbedit is clicked. More...
 
def on_btn_fileedit (self)
 Fired when WordSrcDialog::btn_fileedit is clicked. More...
 
def on_decode_error (self, hiliter, msg, doc, pos, lineno, colno)
 
def on_decode_success (self, hiliter)
 
- 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 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

 src
 dict serialized word source data (see __init__()) More...
 
 layout_controls
 
 gb_name
 
 layout_gb_name
 
 le_name
 
 gb_type
 
 layout_gb_type
 
 rb_type_db
 
 rb_type_file
 
 rb_type_list
 
 stacked
 
 page_db
 
 layout_db
 
 le_dbfile
 
 combo_dbtype
 
 le_dbuser
 
 le_dbpass
 
 te_dbtables
 
 te_dbtables_hiliter
 
 te_te_dbtables_error
 
 layout_dbtables
 
 chb_db_shuffle
 
 btn_dbedit
 
 page_file
 
 layout_file
 
 le_txtfile
 
 combo_fileenc
 
 combo_file_delim
 
 chb_file_shuffle
 
 btn_fileedit
 
 page_list
 
 layout_list
 
 chb_haspos
 
 combo_list_delim
 
 te_wlist
 
 chb_list_shuffle
 
- 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 source editor dialog: provides adding and editing word sources.

The word sources are then combined in gui::MainWindow::wordsrc in their sequential order (as they are shown in the Settings dialog) to use for crossword generation.

Currently 3 types of word sources are supported:

See pycross.wordsrc for implementation of word source objects.

Constructor & Destructor Documentation

◆ __init__()

def pycross.forms.WordSrcDialog.__init__ (   self,
  src = None,
  parent = None,
  flags = QtCore.Qt.WindowFlags() 
)

Constructor.

Parameters
srcdict serialized word source data in the following format:
src = {'active': True|False, 'name': '<name>', 'type': 'db|file|list', 'file': '<path>',
'dbtype': '<sqlite>', 'dblogin': '', 'dbpass': '', 'dbtables': SQL_TABLES,
'haspos': True|False, 'encoding': 'utf-8', 'shuffle': True|False,
'delim': ' ', 'words': []}
Description of keys:
  • 'active' bool whether this source will be used in crossword generation
  • 'name' str unique name for this source, e.g. 'eng-db' or 'rus-text-1'
  • 'type' str any of the three source types:
    • 'db' SQLite database
    • 'file' text file
    • 'list' in-memory list of words
  • 'file' str full path to the DB or text file; if 'type' == 'db', abbreviated paths can be used to point to the preinstalled DB files, e.g. 'ru' = 'assets/dic/ru.db'
  • 'dbtype' str currently must be only 'sqlite' (no other DB types are supported)
  • 'dblogin' str optional DB user name
  • 'dbpass' str optional DB user password
  • 'dbtables' dict SQLite DB table and field names as given in utils::globalvars::SQL_TABLES
  • 'haspos' bool True to indicate that the text file or word list contains part of speech data (appended to word strings after a delimiter character)
  • 'encoding' str text file encoding (default = 'utf-8')
  • 'shuffle' bool whether to shuffle the words in the source randomly when used for word suggestions
  • 'delim' str delimiter character used to delimit word strings and part of speech data (default = whitespace)
  • 'words' list list of words (optionally with part of speech data) – see wordsrc::TextWordsource::words
parentQtWidgets.QWidget parent widget (default = None, i.e. no parent)
flagsQtCore.Qt.WindowFlags Qt window flags

Member Function Documentation

◆ add_pages()

def pycross.forms.WordSrcDialog.add_pages (   self)

Creates tabs for the 3 source types.

◆ addMainLayout()

def pycross.forms.WordSrcDialog.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.

◆ from_src()

def pycross.forms.WordSrcDialog.from_src (   self,
  src 
)

Initializes controls from word source data.

Parameters
srcdict serialized word source data (see __init__())
See also
The reverse method: to_src()

◆ on_btn_dbedit()

def pycross.forms.WordSrcDialog.on_btn_dbedit (   self)

Fired when WordSrcDialog::btn_dbedit is clicked.

Launches the external DB editor (if present in guisettings::CWSettings::settings['plugins']['thirdparty']['dbbrowser']['exepath'])

◆ on_btn_fileedit()

def pycross.forms.WordSrcDialog.on_btn_fileedit (   self)

Fired when WordSrcDialog::btn_fileedit is clicked.

Launches the external text file editor (if present in guisettings::CWSettings::settings['plugins']['thirdparty']['text']['exepath'])

◆ on_decode_error()

def pycross.forms.WordSrcDialog.on_decode_error (   self,
  hiliter,
  msg,
  doc,
  pos,
  lineno,
  colno 
)

◆ on_decode_success()

def pycross.forms.WordSrcDialog.on_decode_success (   self,
  hiliter 
)

◆ rb_toggled()

def pycross.forms.WordSrcDialog.rb_toggled (   self,
  toggled 
)

Fires when WordSrcDialog::rb_type_db is toggled on or off.

Switches to the corresponding tab.

◆ to_src()

def pycross.forms.WordSrcDialog.to_src (   self)

Saves current control values to word source data dictionary (WordSrcDialog::src).

See also
See word source data format in __init__()
The reverse method: from_src()

◆ validate()

def pycross.forms.WordSrcDialog.validate (   self)

Performs various checks of current control values.

Reimplemented from pycross.forms.BasicDialog.

Member Data Documentation

◆ btn_dbedit

pycross.forms.WordSrcDialog.btn_dbedit

◆ btn_fileedit

pycross.forms.WordSrcDialog.btn_fileedit

◆ chb_db_shuffle

pycross.forms.WordSrcDialog.chb_db_shuffle

◆ chb_file_shuffle

pycross.forms.WordSrcDialog.chb_file_shuffle

◆ chb_haspos

pycross.forms.WordSrcDialog.chb_haspos

◆ chb_list_shuffle

pycross.forms.WordSrcDialog.chb_list_shuffle

◆ combo_dbtype

pycross.forms.WordSrcDialog.combo_dbtype

◆ combo_file_delim

pycross.forms.WordSrcDialog.combo_file_delim

◆ combo_fileenc

pycross.forms.WordSrcDialog.combo_fileenc

◆ combo_list_delim

pycross.forms.WordSrcDialog.combo_list_delim

◆ gb_name

pycross.forms.WordSrcDialog.gb_name

◆ gb_type

pycross.forms.WordSrcDialog.gb_type

◆ layout_controls

pycross.forms.WordSrcDialog.layout_controls

◆ layout_db

pycross.forms.WordSrcDialog.layout_db

◆ layout_dbtables

pycross.forms.WordSrcDialog.layout_dbtables

◆ layout_file

pycross.forms.WordSrcDialog.layout_file

◆ layout_gb_name

pycross.forms.WordSrcDialog.layout_gb_name

◆ layout_gb_type

pycross.forms.WordSrcDialog.layout_gb_type

◆ layout_list

pycross.forms.WordSrcDialog.layout_list

◆ le_dbfile

pycross.forms.WordSrcDialog.le_dbfile

◆ le_dbpass

pycross.forms.WordSrcDialog.le_dbpass

◆ le_dbuser

pycross.forms.WordSrcDialog.le_dbuser

◆ le_name

pycross.forms.WordSrcDialog.le_name

◆ le_txtfile

pycross.forms.WordSrcDialog.le_txtfile

◆ page_db

pycross.forms.WordSrcDialog.page_db

◆ page_file

pycross.forms.WordSrcDialog.page_file

◆ page_list

pycross.forms.WordSrcDialog.page_list

◆ rb_type_db

pycross.forms.WordSrcDialog.rb_type_db

◆ rb_type_file

pycross.forms.WordSrcDialog.rb_type_file

◆ rb_type_list

pycross.forms.WordSrcDialog.rb_type_list

◆ src

pycross.forms.WordSrcDialog.src

dict serialized word source data (see __init__())

◆ stacked

pycross.forms.WordSrcDialog.stacked

◆ te_dbtables

pycross.forms.WordSrcDialog.te_dbtables

◆ te_dbtables_hiliter

pycross.forms.WordSrcDialog.te_dbtables_hiliter

◆ te_te_dbtables_error

pycross.forms.WordSrcDialog.te_te_dbtables_error

◆ te_wlist

pycross.forms.WordSrcDialog.te_wlist

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