Exemplo n.º 1
0
 def on_addfield_command(self, event):
     '''
         Add a field
     '''
     result = dialog.textEntryDialog(self, 'Name of new field', 'New field',
                                     'new field')
     if result.accepted:
         field_name = result.text
         fields = self.cfg.get('fields')
         fields_l = [fields[k][0] for k in sorted(fields.keys())]
         if not field_name in fields_l:
             keys = [int(x) for x in fields.keys()]
             if keys:
                 ix = 1 + max(keys)
             else:
                 ix = 1
             new_key = unicode(ix)
             if 1:
                 #a new field has empty options list
                 fields[new_key] = [field_name, []]
             else:
                 #or a new field has a predefined list
                 fields[new_key] = [field_name, ['opt 1', 'opt 2', 'opt 3']]
             self.rename_ix_fields()
             self.populate_table()
         else:
             dialog.messageDialog(self, 'Field already exists.', 'Error',
                                  wx.ICON_ERROR | wx.OK)
Exemplo n.º 2
0
 def showNextWordToGUI(self):
     if len(self.eligibleWords) == 0:
         dialog.messageDialog(self, 'All Words Are Exhausted', 'Alert !!')
         return
     self.selectedWord = random.choice(self.eligibleWords)
     self.eligibleWords.remove(self.selectedWord)
     self.selectedWordMeaning = self.languageMap[self.selectedWord]
     self.components.txtWord.text = self.selectedWord
Exemplo n.º 3
0
 def on_doHelpAbout_command(self, event):
     dialog.messageDialog(self,
                  "Sudoku Solver" + "\n\n" + \
                  "Version %s" % VERSION  + "\n\n" + \
                  "(c) 2005   Alex Tweedly",
                  "About Sudoku Solver",
                  wx.ICON_INFORMATION | wx.OK)
     pass
Exemplo n.º 4
0
	def showNextWordToGUI(self):
		if len(self.eligibleWords) == 0:
			dialog.messageDialog(self, 'All Words Are Exhausted','Alert !!')
			return
		self.selectedWord = random.choice(self.eligibleWords)
		self.eligibleWords.remove(self.selectedWord)
		self.selectedWordMeaning = self.languageMap[self.selectedWord]
		self.components.txtWord.text = self.selectedWord
Exemplo n.º 5
0
 def on_delrec_command(self, evt):
     recordlist = self.components.myGrid.GetSelectedRows()
     if recordlist:
         message = 'Delete records:\n{} ?'.format(recordlist)
         result = dialog.messageDialog(
             self, message, 'Delete',
             wx.ICON_INFORMATION | wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL)
         if result.accepted:
             self.dbTable.DeleteValues(recordlist)
             self.on_tableList_select(None)
     else:
         dialog.messageDialog(self, 'Nothing selected.', 'Info',
                              wx.ICON_INFORMATION | wx.OK)
Exemplo n.º 6
0
 def on_printHelpString_command(self, event):
     itemName = event.target._name[3:]
     for pref in self.prefs:
         if itemName == pref[0]:
             helpText = wrap_string(pref[2], 70)
             result = dialog.messageDialog(self, helpText, \
                                        "Settings Help", wx.ICON_INFORMATION | wx.OK)
Exemplo n.º 7
0
    def on_help_command(self, event):
        '''
            Menu: Help -> Help
        '''
        result = dialog.messageDialog(
            self, '''{}

This program is designed to generate "web config documents"
and is a tool used with a web application server.
The edit part of such documents is used on "web config editor".

The "web config documents" are stored in JSON format.

The "web config editor" is provided by an web application
server and allow admin and normal user to alter properties.

The default structure of new created documents
allow admin of webserver to configure over
web some properties of web application module
such as: groups access, SQL DSN, boolean flags, ...
and also allow normal user to customize its application.

You can change the structure of document by adding
or removing fields, but for "web config documents"
the structure must remain unchanged.
A field in this editor is viewed as an attribute of
selected data entry on "web config editor".

This editor does nothing and know nothing and the real
magic is happening on "web config editor", when the
fields "select" and "mc" (multiple checks) are dinamically
populated using AJAX POST with data provided by webserver.

'''.format(self.components.title.text), 'Help', wx.ICON_INFORMATION
            | wx.OK)  #wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL)
Exemplo n.º 8
0
 def on_close(self, evt):
     result = dialog.messageDialog(self, '''Terminate program and exit?''',
                                   'Exit', wx.ICON_INFORMATION
                                   | wx.YES_NO)  #wx.YES_NO sau wx.OK
     if result.accepted:
         self.Destroy()
         sys.exit(0)
Exemplo n.º 9
0
 def on_save_command(self, event):
     '''
         Save
     '''
     if self.loadedFilename:
         if self.confirmSaveDocument:
             result = dialog.messageDialog(
                 self, 'Confirm save.', 'Save',
                 wx.ICON_INFORMATION | wx.YES_NO)  #wx.YES_NO sau wx.OK
         if not self.confirmSaveDocument or result.accepted:
             filename = self.loadedFilename
             self._saveData(filename)
             dialog.messageDialog(self, 'Saved', 'Saved',
                                  wx.ICON_INFORMATION | wx.OK)
     else:
         self.on_saveas_command(None)
Exemplo n.º 10
0
 def on_addprop_command(self, event):
     '''
         Add a property
     '''
     if self.confirmAddProperty:
         result = dialog.messageDialog(self, 'Add property?', 'Add',
                                       wx.ICON_INFORMATION
                                       | wx.YES_NO)  #wx.YES_NO sau wx.OK
     if not self.confirmAddProperty or result.accepted:
         self.saved_data = self.cfg.get('data').copy()
         fields = self.cfg.get('fields')
         fields_l = [fields[k][0] for k in sorted(fields.keys())]
         keys = [int(x) for x in self.cfg.get('data').keys()]
         if keys:
             ix = 1 + int(max(keys))
         else:
             ix = 1
         new_key = unicode(ix)
         prop = {}
         for i in fields_l:
             prop[i] = ''
         self.cfg['data'].update({new_key: prop})
         self.rename_ix_props()
         self.populate_table()
         self.components.proptable.SetSelection(-1)  #select last entry
         self.on_proptable_mouseDoubleClick(None)
Exemplo n.º 11
0
 def on_load_command(self, event):
     '''
         Load project in json format
     '''
     try:
         if self.changedFlag:
             result = dialog.messageDialog(self, 'Unsaved work.\nContinue?', 'Warning', wx.ICON_WARNING | wx.YES_NO)
             if not result.accepted:
                 return
         result = dialog.openFileDialog(self, 'Load', '', '', '*.json')
         if result.accepted:
             self.filename = result.paths[0]
             self.components.usedFileName.text = self.filename
             f = open(self.filename, "rt")
             d = json.loads(f.read())
             f.close()
             me = self.components
             self.initJALCode = d['initJALCode']
             self.task_list = d['task_list']
             me.picmodel.selection = d['picmodel']
             me.cpufreq.selection = d['cpufreq']
             me.prescaler.selection = d['prescaler']
             me.inittmr0.text = str(d['inittmr0'])
             L = []
             for i, t in enumerate(self.task_list):
                 l = [str(i), str(t['period']), t['name'], t['body']]
                 L.append(l)
             self.components.tasklist.items = L
             self._format_tasklist()
         self.changedFlag = False
         self.on_inittmr0_textUpdate(None)
     except Exception as ex:
         self._error(ex, 'Error loading file')
Exemplo n.º 12
0
 def on_chkallowNameLabelVariation_mouseClick(self, event):
     if not self.components.chkallowNameLabelVariation.checked:
         # no longer allow them to be different
         # should we allow user to choose which one to keep ?
         # resolve if they are currently different
         # or simply leave as is ?
         wName, wClass = self.components.wComponentList.stringSelection.split("  :  ")
         if 'label'  in self.propertyList:
             propName = 'label'
             deriveName = self._parent.convertToValidName(self._comp[wName].label)            
         else:
             propName = 'text'
             deriveName = self._parent.convertToValidName(self._comp[wName].text)
         # do they already match ?
         if wName == deriveName:
             self.components.chkallowNameLabelVariation.checked = False
             return
             
         result = dialog.messageDialog(self, 
                             'Do you want '+propName+' to revert to reflect the name: '+wName,
                             'Empty '+propName,
                             wx.ICON_QUESTION | wx.YES_NO | wx.NO_DEFAULT)
         if result.accepted:
             self.components['fld'+propName].text = wName
             # temporarily allow diff name/label to allow update to happen, then revert
             self.components.chkallowNameLabelVariation.checked = True
             self.updateComponent(propName)
             self.components.chkallowNameLabelVariation.checked = False
         else:
             self.components.chkallowNameLabelVariation.checked = True
Exemplo n.º 13
0
 def doLaunchURL(self, num):
     """Launch a URL."""
     try:
         webbrowser.open(self.links[num][1], 1, 1)
     except webbrowser.Error, e:
         result = dialog.messageDialog(self, "Could not find a runable browser.", "Error launching URL", \
                                    wx.ICON_INFORMATION | wx.OK)
Exemplo n.º 14
0
 def on_saveas_command(self, event):
     '''
         Save As
     '''
     try:
         wildcard = "JSON files (*.json)|*.json|All Files (*.*)|*.*"
         result = dialog.saveFileDialog(wildcard=wildcard)
         if result.accepted:
             filename = result.paths[0]
             self._saveData(filename)
             self.loadedFilename = filename
             dialog.messageDialog(self, 'Saved', 'Saved',
                                  wx.ICON_INFORMATION | wx.OK)
             self.title = self.loadedFilename
     except Exception as ex:
         err = traceback.format_exc()
         dialog.messageDialog(self, err, 'Error', wx.ICON_ERROR | wx.OK)
Exemplo n.º 15
0
 def on_load_command(self, event):
     '''
         Load JSON document
     '''
     try:
         wildcard = "JSON files (*.json)|*.json|All Files (*.*)|*.*"
         result = dialog.openFileDialog(wildcard=wildcard)
         if result.accepted:
             filename = result.paths[0]
             with open(filename, 'rb') as f:
                 self.cfg = json.loads(f.read())
             self.populate_table()
             self.loadedFilename = filename
             self.title = self.loadedFilename
     except Exception as ex:
         err = traceback.format_exc()
         dialog.messageDialog(self, err, 'Error', wx.ICON_ERROR | wx.OK)
Exemplo n.º 16
0
 def on_ok_command(self, event):
     if self.confirmSaveProperty:
         result = dialog.messageDialog(self, 'Confirm save?', 'Save',
                                       wx.ICON_INFORMATION
                                       | wx.YES_NO)  #wx.YES_NO sau wx.OK
     if not self.confirmSaveProperty or result.accepted:
         self.close()
         self.callback(True)
Exemplo n.º 17
0
 def on_doHelpAbout_command(self, event):
     # once we have generic dialogs going, put a more interesting
     # About box here
     if self.documentPath is None:
         filename = self.resource.strings.untitled
     else:
         filename = os.path.basename(self.documentPath)
     countString = "%d " + self.resource.strings.chars + \
         ", %d " + self.resource.strings.words + \
         ", %d " + self.resource.strings.lines
     dialog.messageDialog(self,
                          self.resource.strings.sample + "\n\n" + \
                          self.resource.strings.document + ": %s\n" % filename + \
                          countString \
                          % self.wordCount(self.components.document.text),
                          self.resource.strings.about,
                          wx.ICON_INFORMATION | wx.OK)
Exemplo n.º 18
0
 def on_menuFileStartOver_select(self, event):
     event.skip()
     result = dialog.messageDialog(self, 'Clear all? Are you sure?', 'Are you sure?',
                            wx.ICON_INFORMATION |
                            wx.YES_NO | wx.NO_DEFAULT)
     if result.accepted:
         self.p.initState()
         self.statusChanged()
Exemplo n.º 19
0
 def on_cancel_command(self, event):
     if self.confirmCancelProperty:
         result = dialog.messageDialog(self, 'Confirm cancel?', 'Cancel',
                                       wx.ICON_INFORMATION
                                       | wx.YES_NO)  #wx.YES_NO sau wx.OK
     if not self.confirmCancelProperty or result.accepted:
         self.close()
         self.callback(False)
Exemplo n.º 20
0
 def on_close(self, event):
     '''
         Close application
     '''
     if self.changedFlag:
         result = dialog.messageDialog(self, 'Unsaved work.\nContinue?', 'Warning', wx.ICON_WARNING | wx.YES_NO)
         if not result.accepted:
             return
     self.Destroy()
Exemplo n.º 21
0
 def errDialog(self, errmsg):
     err = traceback.format_exc()
     if len(err) < 6:
         err = ''
     msg = '{}\n\n{}'.format(errmsg, err)
     result = dialog.messageDialog(
         self, msg, 'Runtime error',
         wx.ICON_ERROR | wx.OK)  #wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL)
     self.panel.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
Exemplo n.º 22
0
 def on_DSNList_select(self, event):
     #1 - select DSN
     DSN = self.components.DSNList.stringSelection
     if DSN:
         try:
             self.components.tableList.enabled = True
             self.components.appendRecord.enabled = False
             self.components.deleteRecord.enabled = False
             self.components.Refresh.enabled = False
             dbClass = genericSqlalchemy.browse
             self.db = dbClass(DSN)
             self.components.tableList.items = self.db.getTables()
             self.components.myGrid.SetTable(EmptyTable())
             self.components.myGrid.AutoSizeColumns()
             self.components.myGrid.AdjustScrollbars()
         except Exception as ex:
             dialog.messageDialog(self, str(ex), 'Error',
                                  wx.ICON_ERROR | wx.OK)
Exemplo n.º 23
0
 def on_awayClearButton_mouseClick(self, event):#clear away roster, resetting any previous loading actions
     result = dialog.messageDialog(self, 'Are you sure you want to clear the away roster?',
                       'Clear', wx.YES_NO | wx.ICON_QUESTION)
     if result.returnedString == 'Yes':
         self.components.otherList.Clear()
         self.opponentIDX = -1
         del self.awayRoster[:]
         del self.awayRosterNum[:]
         self.opponent = 'Away Team'
         self.components.awayLabel.text = self.opponent
Exemplo n.º 24
0
 def saveChanges(self):
     # save configuration info in the app directory
     #filename = os.path.basename(self.documentPath)
     if self.documentPath is None:
         filename = "Untitled"
     else:
         filename = self.documentPath
     msg = "The text in the %s file has changed.\n\nDo you want to save the changes?" % filename
     result = dialog.messageDialog(self, msg, 'textEditor', wx.ICON_EXCLAMATION | wx.YES_NO | wx.CANCEL)
     return result.returnedString
Exemplo n.º 25
0
 def on_homeClearButton_mouseClick(self, event):#clear home roster, resetting any previous loading actions
     result = dialog.messageDialog(self, 'Are you sure you want to clear the home roster?',
                       'Clear', wx.YES_NO | wx.ICON_QUESTION)
     if result.returnedString == 'Yes':
         self.components.theList.Clear()
         self.homeIDX = -1
         del self.homeRoster[:]
         del self.homeRosterNum[:]
         self.home = 'Home Team'
         self.components.homeLabel.text = self.home
Exemplo n.º 26
0
 def on_fieldslist_mouseDoubleClick(self, event):
     '''
         Change pick list for a field
     '''
     ix = self.components.fieldslist.selection
     fields = self.cfg.get('fields')
     fields_l = [fields[k][0] for k in sorted(fields.keys())]
     key = sorted(fields.keys())[ix]
     fieldname, options = fields[key]
     result = dialog.textEntryDialog(
         self, 'Edit pick list for\n\n{}'.format(fieldname), 'Edit field',
         '{}'.format(options))
     if result.accepted:
         try:
             value = [unicode(x) for x in eval(result.text)]
             fields[key][1] = value
         except:
             dialog.messageDialog(self, 'Invalid list.', 'Error',
                                  wx.ICON_ERROR | wx.OK)
Exemplo n.º 27
0
 def on_buttonMessage_mouseClick(self, event):
     """
     result = dialog.messageDialog(self, 'a message', 'a title',
                            wx.ICON_ERROR | wx.YES_NO)
     """
     result = dialog.messageDialog(
         self, 'a message', 'a title',
         wx.ICON_INFORMATION | wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL)
     #result = dialog.messageDialog(self, 'a message', 'a title')
     self.components.fldResults.text = "messageDialog result:\naccepted: %s\nreturnedString: %s" % (
         result.accepted, result.returnedString)
Exemplo n.º 28
0
 def on_delButt_mouseUp(self, event):
     result = dialog.messageDialog(
         self, 'Are you sure you want to delete the entry: %s ?' %
         self.rowsDict[self.selected]['name'], 'Delete Entry.')
     if result.accepted:
         print "messageDialog result:\naccepted: %s\nreturnedString: %s" % (
             result.accepted, result.returnedString)
         del self.rowsDict[self.selected]
         self.selected -= 1
         self.showSelected()
         self.store()
Exemplo n.º 29
0
 def on_delBtn_command(self, event):
     msgtxt = 'Are you sure you want to delete "%s"?' % self.components.sessionList.stringSelection
     result = dialog.messageDialog(self, msgtxt, 'Caution!',
         wx.ICON_EXCLAMATION | wx.YES_NO | wx.NO_DEFAULT)
     if result.accepted:
         bull = self.cfg.remove_section(self.components.sessionList.stringSelection)
         fd = open(CONFIG_FILE, 'w')
         self.cfg.write(fd)
         fd.close()
         self.updateSessionList()
         self.components.sessionList.stringSelection = self.components.sessionList.items[0]
Exemplo n.º 30
0
 def on_tableList_select(self, evt):
     #2 - select table
     table = self.components.tableList.stringSelection
     if table:
         try:
             self.db.filter = self.components.filter.text
             self.dbTable = DBTable(self.db, table)
             self.components.myGrid.SetTable(self.dbTable)
             self.components.myGrid.AutoSizeColumns()
             self.components.myGrid.AdjustScrollbars()
             self.components.filter.enabled = True
             self.components.appendRecord.enabled = True
             self.components.deleteRecord.enabled = self.enabledelete
             self.components.Refresh.enabled = True
         except Exception as ex:
             self.components.myGrid.SetTable(EmptyTable())
             self.components.myGrid.AutoSizeColumns()
             self.components.myGrid.AdjustScrollbars()
             dialog.messageDialog(self, str(ex), 'Error',
                                  wx.ICON_ERROR | wx.OK)
Exemplo n.º 31
0
 def on_initialize(self, event):
     #init
     if getattr(sys, 'frozen', False):
         self.DATAFOLDER = string.join((os.getcwd(), '..'), os.sep)
     else:
         self.DATAFOLDER = os.getcwd()
     configFilename = string.join((self.DATAFOLDER, "config.ini"), os.sep)
     self.config = getPropsDict(configFilename, '=')  #sep is '='
     self.components.title.text = self.config.get('title',
                                                  'SQL Table Editor')
     self.title = self.components.title.text
     self.components.tableList.items = []
     self.components.tableList.enabled = False
     self.components.appendRecord.enabled = False
     self.components.deleteRecord.enabled = False
     self.components.Refresh.enabled = False
     self.components.filter.text = ''
     self.components.filter.enabled = False
     DSN = self.config.get('DSN', [])
     if type(DSN) == type([]):
         self.components.DSNList.items = DSN
     else:
         self.components.DSNList.items = [DSN]
         self.components.DSNList.selection = 0
         self.components.DSNList.stringSelection = DSN
         self.on_DSNList_select(None)
     accesspassword = self.config.get('accesspassword', None)
     accessprompt = self.config.get('accessprompt', 'Access Password:'******'enabledelete', False):
         self.enabledelete = True
     else:
         self.enabledelete = False
     if accesspassword:
         result = dialog.passwordTextEntryDialog(self, accessprompt,
                                                 accessprompt, '')
         if accesspassword == result.text:
             dialog.messageDialog(
                 self, '''Ok!''', accessprompt, wx.ICON_INFORMATION
                 | wx.OK)  #wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL)
         else:
             sys.exit(1)
Exemplo n.º 32
0
    def on_about_command(self, event):
        result = dialog.messageDialog(self, '''JAL Code Generator

(C) 2017 Ioan Coman
http://rainbowheart.ro/

wx version: {}

Python version:
{}

'''.format(wx.version(), sys.version), 'About', wx.ICON_INFORMATION | wx.OK) #wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL)
Exemplo n.º 33
0
    def on_mygrid_editorHidden(self, event):
        if event.row == 6 and event.column == 3:
            result = dialog.messageDialog(
                self, "Are you sure you wish to finish editing this cell?",
                "Checking", wx.YES_NO)
            if not result.accepted:
                event.Veto()
                return

        self.log.write("on_mygrid_editorHidden: (%d,%d) %s\n" %
                       (event.row, event.column, event.position))
        event.skip()
Exemplo n.º 34
0
 def on_picmodel_select(self, event):
     '''
         When pic model is changed,
         the initJALCode section is updated
     '''
     if self.changedFlag:
         result = dialog.messageDialog(self, 'Unsaved work.\nContinue?', 'Warning', wx.ICON_WARNING | wx.YES_NO)
         if not result.accepted:
             return
     me = self.components
     self.initJALCode = self.config.get(me.picmodel.items[me.picmodel.selection], '-- no init defined in config')
     self.changedFlag = False
Exemplo n.º 35
0
    def sleep_test(self):
        if self.sleeping:
            result = dialog.messageDialog(self, """WARNING!
Your pet is sleeping, if you wake him up he'll be unhappy!
Do you want to proceed?""", 'WARNING!', 
wx.ICON_EXCLAMATION | wx.YES_NO | wx.NO_DEFAULT)

            if result.accepted:
                self.sleeping = False
                self.happiness -= 4
                self.forceAwake = True
                return True
            else:
                return False
        else:
            return True
Exemplo n.º 36
0
    def on_menuLoadRuleset_select(self, event):
        event.skip()
        result = dialog.messageDialog(self, 'Currently, loading a new ruleset will CLEAR ALL MEETING HISTORY AND STATUS, just like Start Over. Are you sure you want to clear all?', 'Are you sure?',
                               wx.ICON_EXCLAMATION |
                               wx.YES_NO | wx.NO_DEFAULT)

        if result.accepted:
            wildcard = "Ruleset files (*_ruleset.py)|*_ruleset.py|All Files (*.*)|*.*"
            result = dialog.openFileDialog(wildcard=wildcard)

            if result.accepted:
                path = result.paths[0]
                global p
                self.setParliamentInstance(Parliament.Parliament(path))
                self.p.initState()
                self.statusChanged()
Exemplo n.º 37
0
 def featureNotImplementedYet(self):
     result = dialog.messageDialog(self, 'This feature not implemented yet.', 'Not implemented',
                            wx.ICON_EXCLAMATION |
                            wx.OK)
Exemplo n.º 38
0
 def saveChanges(self):
     msg = "The World Map has changed.\n\nDo you want to save the changes?"
     result = dialog.messageDialog(self, msg, 'World Editor', wx.ICON_EXCLAMATION | wx.YES_NO | wx.CANCEL)
     return result.returnedString