def createPopupMenu(self, pos=None): if pos is None: menu = KTextEdit.createPopupMenu(self) else: menu = KTextEdit.createPopupMenu(self, pos) #ident = menu.insertItem('Hello There', self.slotHelloThere) #if self.hasSelectedText(): # print self.selectedText() # print self.getSelection() #print 'ident', ident #menu.setItemParameter(ident, 777) env = self.trait.get_full_environment() # make a magic number to start id's on variables varcount = 1234 lookup = {} for trait, traitvars in env: tmenu = QPopupMenu(menu) menu.insertItem(trait, tmenu) keys = traitvars.keys() keys.sort() for key in keys: varcount += 1 ident = tmenu.insertItem(key, self.slotPopupMenuItemSelected) tmenu.setItemParameter(ident, varcount) lookup[varcount] = (trait, key) self.lookup = lookup menu.insertItem('Create New Variable', self.slotCreateNewVariable) return menu
def __init__(self, parent): VboxDialog.__init__(self, parent, 'NewMTScriptDialog') self.scriptnameBox = MTScriptCombo(self.page) self.scriptdataBox = KTextEdit(self.page) self.vbox.addWidget(self.scriptnameBox) self.vbox.addWidget(self.scriptdataBox) self.show()
def __init__(self, parent, handler): VboxDialog.__init__(self, parent) self.diskconfig = handler self.diskconfigLbl = QLabel(self.frame) self.diskconfigLbl.setText('DiskConfig Name') self.diskconfigEntry = KLineEdit(self.frame) self.contentLbl = QLabel(self.frame) self.contentLbl.setText('DiskConfig Content') self.contentEntry = KTextEdit(self.frame) self.vbox.addWidget(self.diskconfigLbl) self.vbox.addWidget(self.diskconfigEntry) self.vbox.addWidget(self.contentLbl) self.vbox.addWidget(self.contentEntry) self.connect(self, SIGNAL('okClicked()'), self.slotOkClicked)
def __init__(self, parent, name='BaseGuestDataFrame'): QFrame.__init__(self, parent, name) self.guestid = None numrows = 2 numcols = 2 margin = 0 space = 1 self.grid = QGridLayout(self, numrows, numcols, margin, space, 'BaseGuestDataLayout') self.app = get_application_pointer() self.fname_lbl = QLabel('First Name', self) self.fname_entry = KLineEdit('', self) self.grid.addWidget(self.fname_lbl, 0, 0) self.grid.addWidget(self.fname_entry, 1, 0) self.lname_lbl = QLabel('Last Name', self) self.lname_entry = KLineEdit('', self) self.grid.addWidget(self.lname_lbl, 0, 1) self.grid.addWidget(self.lname_entry, 1, 1) self.title_lbl = QLabel('Title', self) self.title_entry = KLineEdit('', self) self.grid.addMultiCellWidget(self.title_lbl, 2, 2, 0, 1) self.grid.addMultiCellWidget(self.title_entry, 3, 3, 0, 1) self.desc_lbl = QLabel('Description', self) self.desc_entry = KTextEdit(self, 'description_entry') self.grid.addMultiCellWidget(self.desc_lbl, 4, 4, 0, 1) self.grid.addMultiCellWidget(self.desc_entry, 5, 7, 0, 1)
def __init__(self, parent, name='NewAptKeyDialog'): VBoxDialog.__init__(self, parent, name=name) self.name_label = QLabel('name', self.vbox) self.name_entry = KLineEdit(self.vbox) self.data_lable = QLabel('data', self.vbox) self.data_entry = KTextEdit(self.vbox) self.resize(300, 500) self.setCaption('Enter new key')
def __init__(self, parent, clientid, name='TroubleDialog'): VboxDialog.__init__(self, parent, name) self.clientid = clientid self.problemEdit = KLineEdit('', self.page) self.magnetBox = MyCombo(self.page) self.worktodoEdit = KTextEdit(self.page) self.vbox.addWidget(self.problemEdit) self.vbox.addWidget(self.magnetBox) self.vbox.addWidget(self.worktodoEdit) self.showButtonApply(False) self.setButtonOKText('insert', 'insert') self.show()
class NewMachineScriptDialog(VboxDialog): def __init__(self, parent): VboxDialog.__init__(self, parent, 'NewMachineScriptDialog') self.scriptnameBox = MachineScriptComboBox(self.frame) self.scriptdataBox = KTextEdit(self.frame) self.vbox.addWidget(self.scriptnameBox) self.vbox.addWidget(self.scriptdataBox) def getRecordData(self): name = str(self.scriptnameBox.currentText()) data = str(self.scriptdataBox.text()) return dict(name=name, data=data)
class NewMTScriptDialog(VboxDialog): def __init__(self, parent): VboxDialog.__init__(self, parent, 'NewMTScriptDialog') self.scriptnameBox = MTScriptComboBox(self.frame) self.scriptdataBox = KTextEdit(self.frame) self.vbox.addWidget(self.scriptnameBox) self.vbox.addWidget(self.scriptdataBox) def getRecordData(self): name = str(self.scriptnameBox.currentText()) data = str(self.scriptdataBox.text()) return dict(name=name, data=data)
def __init__(self, parent, name='BaseEntityDataFrame'): AppFrame.__init__(self, parent, name) self.entityid = None numrows = 2 numcols = 1 margin = 3 space = 2 self.grid = QGridLayout(self, numrows, numcols, margin, space, 'BaseEntityDataLayout') self.app = get_application_pointer() self.name_lbl = QLabel('Name', self) self.name_entry = KLineEdit('', self) self.grid.addWidget(self.name_lbl, 0, 0) self.grid.addWidget(self.name_entry, 1, 0) self.etype_lbl = QLabel('type', self) self.etype_combo = KComboBox(self, 'etype_combo') db = self.app.db etypes = db.session.query(db.EntityType).all() self.etype_combo.insertStrList([e.type for e in etypes]) self.connect(self.etype_combo, SIGNAL('activated(const QString &)'), self.change_etype) self.grid.addWidget(self.etype_lbl, 2, 0) self.grid.addWidget(self.etype_combo, 3, 0) self.url_lbl = QLabel('url', self) self.url_entry = KLineEdit('', self) self.grid.addWidget(self.url_lbl, 4, 0) self.grid.addWidget(self.url_entry, 5, 0) grid_rownum = 6 self.desc_lbl = QLabel('Description', self) self.desc_entry = KTextEdit(self, 'description_entry') self.desc_entry.setTextFormat(self.PlainText) self.grid.addMultiCellWidget(self.desc_lbl, 6, 6, 0, 0) self.grid.addMultiCellWidget(self.desc_entry, 7, 10, 0, 0)
class TroubleDialog(VboxDialog): def __init__(self, parent, clientid, name='TroubleDialog'): VboxDialog.__init__(self, parent, name) self.clientid = clientid self.problemEdit = KLineEdit('', self.page) self.magnetBox = MyCombo(self.page) self.worktodoEdit = KTextEdit(self.page) self.vbox.addWidget(self.problemEdit) self.vbox.addWidget(self.magnetBox) self.vbox.addWidget(self.worktodoEdit) self.showButtonApply(False) self.setButtonOKText('insert', 'insert') self.show() def getRecordData(self): problem = str(self.problemEdit.text()) worktodo = str(self.worktodoEdit.text()) return dict(problem=problem, worktodo=worktodo, clientid=self.clientid)
class NewDiskConfigDialog(VboxDialog): def __init__(self, parent, handler): VboxDialog.__init__(self, parent) self.diskconfig = handler self.diskconfigLbl = QLabel(self.frame) self.diskconfigLbl.setText('DiskConfig Name') self.diskconfigEntry = KLineEdit(self.frame) self.contentLbl = QLabel(self.frame) self.contentLbl.setText('DiskConfig Content') self.contentEntry = KTextEdit(self.frame) self.vbox.addWidget(self.diskconfigLbl) self.vbox.addWidget(self.diskconfigEntry) self.vbox.addWidget(self.contentLbl) self.vbox.addWidget(self.contentEntry) self.connect(self, SIGNAL('okClicked()'), self.slotOkClicked) def slotOkClicked(self): name = str(self.diskconfigEntry.text()) content = str(self.contentEntry.text()) self.diskconfig.set(name, dict(content=content))
def __init__(self, app, parent): KTextEdit.__init__(self, parent) self.app = app
class BaseGuestDataFrame(QFrame): def __init__(self, parent, name='BaseGuestDataFrame'): QFrame.__init__(self, parent, name) self.guestid = None numrows = 2 numcols = 2 margin = 0 space = 1 self.grid = QGridLayout(self, numrows, numcols, margin, space, 'BaseGuestDataLayout') self.app = get_application_pointer() self.fname_lbl = QLabel('First Name', self) self.fname_entry = KLineEdit('', self) self.grid.addWidget(self.fname_lbl, 0, 0) self.grid.addWidget(self.fname_entry, 1, 0) self.lname_lbl = QLabel('Last Name', self) self.lname_entry = KLineEdit('', self) self.grid.addWidget(self.lname_lbl, 0, 1) self.grid.addWidget(self.lname_entry, 1, 1) self.title_lbl = QLabel('Title', self) self.title_entry = KLineEdit('', self) self.grid.addMultiCellWidget(self.title_lbl, 2, 2, 0, 1) self.grid.addMultiCellWidget(self.title_entry, 3, 3, 0, 1) self.desc_lbl = QLabel('Description', self) self.desc_entry = KTextEdit(self, 'description_entry') self.grid.addMultiCellWidget(self.desc_lbl, 4, 4, 0, 1) self.grid.addMultiCellWidget(self.desc_entry, 5, 7, 0, 1) #self.works_frame = BaseGuestWorksFrame(self) #self.grid.addMultiCellWidget(self.works_frame, 8, 8, 0, 1) def get_guest_data(self): fname = str(self.fname_entry.text()) lname = str(self.lname_entry.text()) title = str(self.title_entry.text()) desc = str(self.desc_entry.text()) # take the newlines out for now # until the sqlgen is fixed to work with sqlite desc = desc.replace('\n', ' ') data = dict(firstname=fname, lastname=lname, description=desc, title=title) if self.guestid is not None: data['guestid'] = self.guestid return data def set_guest_data(self, data): self.guestid = data['guestid'] self.fname_entry.setText(data['firstname']) self.lname_entry.setText(data['lastname']) if data['title']: self.title_entry.setText(data['title']) if data['description']: desc = data['description'] desc = self.app.guests.unescape_text(desc) self.desc_entry.setText(desc)
def __init__(self, parent, name='BaseGameDataFrame'): QFrame.__init__(self, parent, name) # there will be more than two rows, but we'll start with two numrows = 2 # there should onlty be two columns numcols = 2 margin = 0 space = 1 # add a grid layout to the frame self.grid = QGridLayout(self, numrows, numcols, margin, space, 'BaseGameDataLayout') # make a couple of lists to point to the weblink entries # order is important in these lists self.weblink_site_entries = [] self.weblink_url_entries = [] # I may use dict[site] = (site_entry, url_entry) # I haven't decided yet. It could always be formed by zipping the 2 lists above. self.weblink_dict = {} # setup app pointer self.app = KApplication.kApplication() self.myconfig = self.app.myconfig # setup dialog pointers self.select_launch_command_dlg = None # Setup widgets # setup name widgets self.name_lbl = QLabel('<b>Name</b>', self) self.name_entry = KLineEdit('', self) # add name widgets to grid self.grid.addWidget(self.name_lbl, 0, 0) self.grid.addWidget(self.name_entry, 1, 0) # setup fullname widgets self.fullname_lbl = QLabel('<b>Full name</b>', self) self.fullname_entry = KLineEdit('', self) # add fullname widgets self.grid.addWidget(self.fullname_lbl, 2, 0) self.grid.addWidget(self.fullname_entry, 3, 0) # setup description widgets self.desc_lbl = QLabel('<b>Description</b>', self) self.desc_entry = KTextEdit(self, 'description_entry') # set plain text format for description entry # we do this in case there are html tags in the entry self.desc_entry.setTextFormat(self.PlainText) # add description widgets self.grid.addWidget(self.desc_lbl, 4, 0) #self.addWidget(self.desc_entry, 5, 0) # add the description as a multirow entity # default from 5 to 15 # this allows for weblinks to be added # (about 5) # without the dialog looking ugly # going to 15 won't force there to be that many rows # until more enough widgets are added self.grid.addMultiCellWidget(self.desc_entry, 5, 15, 0, 0) # setup launch command widgets self.launch_lbl = QLabel('<b>Launch command</b>', self) self.launch_entry = KLineEdit('', self) self.launch_dlg_button = KPushButton('...', self, 'launch_dlg_button') self.launch_dlg_button.connect(self.launch_dlg_button, SIGNAL('clicked()'), self.select_launch_command) # add launch command widgets self.grid.addWidget(self.launch_lbl, 0, 1) self.grid.addWidget(self.launch_entry, 1, 1) self.grid.addWidget(self.launch_dlg_button, 1, 2) # setup dosboxpath widgets self.dosboxpath_lbl = QLabel('<b>dosbox path</b>', self) self.dosboxpath_entry = KLineEdit('', self) # add dosboxpath widgets self.grid.addWidget(self.dosboxpath_lbl, 2, 1) self.grid.addWidget(self.dosboxpath_entry, 3, 1) # setup main weblink widgets self.weblinks_lbl = QLabel('<b>weblinks</b>', self) self.weblinks_btn = KPushButton('+', self, 'add_weblink_button') self.weblinks_btn.connect(self.weblinks_btn, SIGNAL('clicked()'), self.add_weblink_entries) # add main weblink widgets self.grid.addWidget(self.weblinks_lbl, 4, 1) self.grid.addWidget(self.weblinks_btn, 4, 2)
class BaseGameDataFrame(QFrame): def __init__(self, parent, name='BaseGameDataFrame'): QFrame.__init__(self, parent, name) # there will be more than two rows, but we'll start with two numrows = 2 # there should onlty be two columns numcols = 2 margin = 0 space = 1 # add a grid layout to the frame self.grid = QGridLayout(self, numrows, numcols, margin, space, 'BaseGameDataLayout') # make a couple of lists to point to the weblink entries # order is important in these lists self.weblink_site_entries = [] self.weblink_url_entries = [] # I may use dict[site] = (site_entry, url_entry) # I haven't decided yet. It could always be formed by zipping the 2 lists above. self.weblink_dict = {} # setup app pointer self.app = KApplication.kApplication() self.myconfig = self.app.myconfig # setup dialog pointers self.select_launch_command_dlg = None # Setup widgets # setup name widgets self.name_lbl = QLabel('<b>Name</b>', self) self.name_entry = KLineEdit('', self) # add name widgets to grid self.grid.addWidget(self.name_lbl, 0, 0) self.grid.addWidget(self.name_entry, 1, 0) # setup fullname widgets self.fullname_lbl = QLabel('<b>Full name</b>', self) self.fullname_entry = KLineEdit('', self) # add fullname widgets self.grid.addWidget(self.fullname_lbl, 2, 0) self.grid.addWidget(self.fullname_entry, 3, 0) # setup description widgets self.desc_lbl = QLabel('<b>Description</b>', self) self.desc_entry = KTextEdit(self, 'description_entry') # set plain text format for description entry # we do this in case there are html tags in the entry self.desc_entry.setTextFormat(self.PlainText) # add description widgets self.grid.addWidget(self.desc_lbl, 4, 0) #self.addWidget(self.desc_entry, 5, 0) # add the description as a multirow entity # default from 5 to 15 # this allows for weblinks to be added # (about 5) # without the dialog looking ugly # going to 15 won't force there to be that many rows # until more enough widgets are added self.grid.addMultiCellWidget(self.desc_entry, 5, 15, 0, 0) # setup launch command widgets self.launch_lbl = QLabel('<b>Launch command</b>', self) self.launch_entry = KLineEdit('', self) self.launch_dlg_button = KPushButton('...', self, 'launch_dlg_button') self.launch_dlg_button.connect(self.launch_dlg_button, SIGNAL('clicked()'), self.select_launch_command) # add launch command widgets self.grid.addWidget(self.launch_lbl, 0, 1) self.grid.addWidget(self.launch_entry, 1, 1) self.grid.addWidget(self.launch_dlg_button, 1, 2) # setup dosboxpath widgets self.dosboxpath_lbl = QLabel('<b>dosbox path</b>', self) self.dosboxpath_entry = KLineEdit('', self) # add dosboxpath widgets self.grid.addWidget(self.dosboxpath_lbl, 2, 1) self.grid.addWidget(self.dosboxpath_entry, 3, 1) # setup main weblink widgets self.weblinks_lbl = QLabel('<b>weblinks</b>', self) self.weblinks_btn = KPushButton('+', self, 'add_weblink_button') self.weblinks_btn.connect(self.weblinks_btn, SIGNAL('clicked()'), self.add_weblink_entries) # add main weblink widgets self.grid.addWidget(self.weblinks_lbl, 4, 1) self.grid.addWidget(self.weblinks_btn, 4, 2) def select_launch_command(self): if self.select_launch_command_dlg is None: file_filter = "*.exe *.bat *.com|Dos Executables\n*|All Files" dlg = KFileDialog(self.fullpath, file_filter, self, 'select_launch_command_dlg', True) dlg.connect(dlg, SIGNAL('okClicked()'), self.launch_command_selected) dlg.connect(dlg, SIGNAL('cancelClicked()'), self.destroy_select_launch_command_dlg) dlg.connect(dlg, SIGNAL('closeClicked()'), self.destroy_select_launch_command_dlg) dlg.show() self.select_launch_command_dlg = dlg else: # we shouldn't need this with a modal dialog KMessageBox.error(self, opendlg_errormsg) def destroy_select_launch_command_dlg(self): self.select_launch_command_dlg = None def launch_command_selected(self): dlg = self.select_launch_command_dlg url = dlg.selectedURL() fullpath = str(url.path()) launch_command = os.path.basename(fullpath) self.launch_entry.setText(launch_command) self.select_launch_command_dlg = None def add_weblink_entries(self, site='', url=''): #we start at row #5 column 1 for lbl column 2 for entry num_entries = len(self.weblink_url_entries) # we need to add 1 on lbl_num because the entries can be appended # until instantiated lbl_num = num_entries + 1 site_lbl = QLabel('<b>site %d</b>' % lbl_num, self) site_entry = KLineEdit(site, self) self.weblink_site_entries.append(site_entry) url_lbl = QLabel('<b>url %d</b>' % lbl_num, self) url_entry = KLineEdit(url, self) self.weblink_url_entries.append(url_entry) if len(self.weblink_site_entries) != len(self.weblink_url_entries): KMessageBox.error(self, 'entries mismatch, something really bad happened.') import sys sys.exit(1) # we need a little math here to figure out the rows # for the widgets # num_entries should now be 1 greater than above num_entries = len(self.weblink_url_entries) site_row = 2*num_entries + 3 url_row = 2*num_entries + 4 # add weblink widgets to the grid top = self.grid.AlignTop self.grid.addWidget(site_entry, site_row, 1) self.grid.addWidget(site_lbl, site_row, 2) self.grid.addWidget(url_entry, url_row, 1) self.grid.addWidget(url_lbl, url_row, 2) # we have to call .show() explicitly on the widgets # as the rest of the widgets are already visible # when show was called on the dialog # show() automatically calls show() on all children for widget in [site_lbl, site_entry, url_lbl, url_entry]: widget.show()
def __init__(self, app, parent): KTextEdit.__init__(self, parent) self.app = app self.hl = TemplateHighlighter(self)
def __init__(self, parent): KTextEdit.__init__(self, parent) self.app = get_application_pointer() self.hl = TemplateHighlighter(self)
def __init__(self, parent): VboxDialog.__init__(self, parent, 'NewMachineScriptDialog') self.scriptnameBox = MachineScriptComboBox(self.frame) self.scriptdataBox = KTextEdit(self.frame) self.vbox.addWidget(self.scriptnameBox) self.vbox.addWidget(self.scriptdataBox)
class BaseEntityDataFrame(AppFrame): def __init__(self, parent, name='BaseEntityDataFrame'): AppFrame.__init__(self, parent, name) self.entityid = None numrows = 2 numcols = 1 margin = 3 space = 2 self.grid = QGridLayout(self, numrows, numcols, margin, space, 'BaseEntityDataLayout') self.app = get_application_pointer() self.name_lbl = QLabel('Name', self) self.name_entry = KLineEdit('', self) self.grid.addWidget(self.name_lbl, 0, 0) self.grid.addWidget(self.name_entry, 1, 0) self.etype_lbl = QLabel('type', self) self.etype_combo = KComboBox(self, 'etype_combo') db = self.app.db etypes = db.session.query(db.EntityType).all() self.etype_combo.insertStrList([e.type for e in etypes]) self.connect(self.etype_combo, SIGNAL('activated(const QString &)'), self.change_etype) self.grid.addWidget(self.etype_lbl, 2, 0) self.grid.addWidget(self.etype_combo, 3, 0) self.url_lbl = QLabel('url', self) self.url_entry = KLineEdit('', self) self.grid.addWidget(self.url_lbl, 4, 0) self.grid.addWidget(self.url_entry, 5, 0) grid_rownum = 6 self.desc_lbl = QLabel('Description', self) self.desc_entry = KTextEdit(self, 'description_entry') self.desc_entry.setTextFormat(self.PlainText) self.grid.addMultiCellWidget(self.desc_lbl, 6, 6, 0, 0) self.grid.addMultiCellWidget(self.desc_entry, 7, 10, 0, 0) #self.works_frame = BaseGuestWorksFrame(self) #self.grid.addMultiCellWidget(self.works_frame, 8, 8, 0, 1) def change_etype(self, etype): print 'change_etype', etype def get_data(self): name = str(self.name_entry.text()) etype = str(self.etype_combo.currentText()) url = str(self.url_entry.text()) desc = str(self.desc_entry.text()) data = dict(name=name, type=etype, url=url, desc=desc) if self.entityid is not None: data['entityid'] = self.entityid return data def set_entity(self, entity): self.entity = entity self.set_data(entity) def set_data(self, entity): self.entityid = entity.entityid self.name_entry.setText(entity.name) self.etype_combo.setCurrentText(entity.type) self.url_entry.setText(entity.url) self.desc_entry.setText(entity.desc)