''' from Tkinter import Button, END, Label, W from Pmw import initialise, ComboBox, Counter top = initialise() lb = Label(top, text='Animals (in pairs; min:pair,max:dozen)') lb.pack() ct = Counter(top, labelpos=W, label_text='Number:', datatype='integer', entryfield_value=2, increment=2, entryfield_validate={ 'validator': 'integer', 'min': 2, 'max': 12 }) ct.pack() cb = ComboBox(top, labelpos=W, label_text='type:') for animal in ('dog', 'cat', 'hamster', 'python'): cb.insert(END, animal) cb.pack() qb = Button(top, text='QUIT', command=top.quit, bg='red', fg='white') qb.pack() top.mainloop()
def __init__(self, editor, parent=None, **kwargs): MegaToplevel.__init__(self, parent) self.editor = editor self.hull = self.component('hull') self.hull.geometry('400x625') self.menuFrame = Frame(self.hull, relief=GROOVE, bd=2) self.menuFrame.pack(fill=X) self.menuBar = MenuBar(self.menuFrame, hotkeys=1) self.menuBar.pack(side=LEFT, expand=1, fill=X) self.menuBar.addmenu('File', 'File') self.menuBar.addmenuitem('File', 'command', 'Load resources from directory', label='Load resources', command=self.editor.loadResources) self.menuBar.addmenuitem('File', 'command', 'Create new world', label='New world', command=self.newWorld) self.menuBar.addmenuitem('File', 'command', 'Create new location', label='New location', command=self.newLocation) self.menuBar.addmenuitem('File', 'command', 'Open world', label='Open', command=self.editor.loadWorld) self.menuBar.addmenuitem('File', 'command', 'Save world', label='Save', command=self.editor.saveWorld) self.notebook = NoteBook(self.hull) self.notebook.pack(fill=BOTH, expand=1) self.currentModel = '' self.modelPage = self.notebook.add('Models') self.otherPage = self.notebook.add('Other') self.modelLabel = Label(self.modelPage, text='Models', font=('Segoe UI', 14, '')) self.modelLabel.pack(expand=0) self.otherLabel = Label(self.otherPage, text='Other', font=('Segoe UI', 14, '')) self.otherLabel.pack(expand=0) self.addFamilyButton = Button(self.otherPage, text='Add Family', command=self.addFamily) self.addFamilyButton.pack() self.addFamilyButton.configure(state='disable') self.addFamilyDialog = Dialog(buttons=('Add Family',), title='Add Family', command=self.editor.addFamily) self.addFamilyDialog.geometry('300x300') self.addFamilyDialog.withdraw() self.addFamilyLabel = Label(self.addFamilyDialog.interior(), text='Set the new family file') self.addFamilyLabel.pack() self.addFamilyField = EntryField(self.addFamilyDialog.interior()) self.addFamilyField.pack(fill=BOTH, expand=1) self.addLinkButton = Button(self.otherPage, text='Add Link', command=self.addLink) self.addLinkButton.pack() self.addLinkButton.configure(state='disable') self.addLinkDialog = Dialog(buttons=('Add Link',), title='Add Link', command=self.editor.addLink) self.addLinkDialog.geometry('300x300') self.addLinkDialog.withdraw() self.addLinkLabel = Label(self.addLinkDialog.interior(), text='Set link name and select direction') self.addLinkLabel.pack() self.addLinkField = EntryField(self.addLinkDialog.interior()) self.addLinkField.pack(fill=BOTH, expand=1) self.addLinkBox = Listbox(self.addLinkDialog.interior()) self.addLinkBox.pack(fill=BOTH, expand=1) for item in ['Bi-directional', 'Direction 1', 'Direction 2']: self.addLinkBox.insert(END, item) self.addTableButton = Button(self.otherPage, text='Add Table', command=self.addTable) self.addTableButton.pack() self.addTableButton.configure(state='disable') self.addTableDialog = Dialog(buttons=('Add Table',), title='Add Table', command=self.editor.addTable) self.addTableDialog.geometry('300x300') self.addTableDialog.withdraw() self.addTableLabel = Label(self.addTableDialog.interior(), text='Set table name and data') self.addTableLabel.pack() self.addTableName = EntryField(self.addTableDialog.interior()) self.addTableName.pack(fill=BOTH, expand=1) self.addTableData = EntryField(self.addTableDialog.interior()) self.addTableData.pack(fill=BOTH, expand=1) self.updateObjButton = Button(self.otherPage, text='Update Object', command=self.updateObj) self.updateObjButton.pack() self.updateObjButton.configure(state='disable') self.updateObjDialog = Dialog(buttons=('Update Object',), title='Update Object', command=self.editor.updateObj) self.updateObjDialog.geometry('300x300') self.updateObjDialog.withdraw() self.updateObjLabel = Label(self.updateObjDialog.interior(), text='Set a field name then data in object') self.updateObjLabel.pack() self.updateObjName = EntryField(self.updateObjDialog.interior()) self.updateObjName.pack(fill=BOTH, expand=1) self.updateObjData = EntryField(self.updateObjDialog.interior()) self.updateObjData.pack(fill=BOTH, expand=1) self.loadModelButton = Button(self.modelPage, text='Load model', command=self.loadModel) self.loadModelButton.pack(padx=20, pady=10) self.loadModelButton.configure(state='disable') self.modelSelector = ComboBox(self.modelPage, dropdown=0, listheight=200, entry_width=30, selectioncommand=self.setModel) self.modelSelector.pack(expand=1, fill=BOTH) self.newWorldDialog = Dialog(buttons=('Create World',), title='New World', command=self.editor.newWorld) self.newWorldDialog.geometry('300x300') self.newWorldDialog.withdraw() self.newWorldLabel = Label(self.newWorldDialog.interior(), text='Set the name of the world') self.newWorldLabel.pack() self.newWorldField = EntryField(self.newWorldDialog.interior()) self.newWorldField.pack(fill=BOTH, expand=1) self.newLocationDialog = Dialog(buttons=('Create Location',), title='New Location', command=self.editor.newLocation) self.newLocationDialog.geometry('350x100') self.newLocationDialog.withdraw() self.newLocationLabel = Label(self.newLocationDialog.interior(), text='Set the name then model of the location') self.newLocationLabel.pack() self.newLocationNameField = EntryField(self.newLocationDialog.interior()) self.newLocationNameField.pack(fill=BOTH, expand=1) self.newLocationModelField = EntryField(self.newLocationDialog.interior()) self.newLocationModelField.pack(fill=BOTH, expand=1) self.newModelDialog = Dialog(buttons=('Create Object',), title='New Model', command=self.editor.loadModel) self.newModelDialog.geometry('250x150') self.newModelDialog.withdraw() self.newModelHeight = 150 self.newModelLabel = Label(self.newModelDialog.interior(), text='Set the type, name (optional), color (optional)\n of the object, and any other fields...') self.newModelLabel.pack() self.newModelType = EntryField(self.newModelDialog.interior()) self.newModelType.pack(fill=BOTH, expand=1) self.newModelName = EntryField(self.newModelDialog.interior()) self.newModelName.pack(fill=BOTH, expand=1) self.newModelColor = EntryField(self.newModelDialog.interior()) self.newModelColor.pack(fill=BOTH, expand=1) self.newModelPlus = Button(self.newModelDialog.interior(), text='+', command=self.plusField) self.newModelPlus.pack(fill=BOTH, expand=1) self.newModelFields = [] self.initialiseoptions(LevelEditorWindow)
#!/usr/bin/env python from Tkinter import Button, END, Label, W from Pmw import initialise, ComboBox, Counter top = initialise() lb = Label(top, text='animals (in pairs; min: pair, max: dozen)') lb.pack() ct = Counter(top, labelpos=W, label_text='number:', datatype='integer', entryfield_value=2, increment=2, entryfield_validate={'validator': 'integer', 'min':2, 'max':12}) ct.pack() cb = ComboBox(top, labelpos=W, label_text='type:') for animal in ('dog', 'cat', 'hamster', 'python'): cb.insert(END, animal) cb.pack() qb = Button(top, text='quit', command=top.quit, bg='red', fg='white') qb.pack() top.mainloop()
#!/usr/bin/env python from Tkinter import Button from Tkinter import END from Tkinter import Label from Tkinter import W from Pmw import initialise from Pmw import ComboBox from Pmw import Counter top = initialise() lb = Label(top, textx='Animals (in pairs; min: pair, max: dozen)') lb.pack() ct = Counter(top, labelpos=W, label_text='Number:', datatype='integer', entryfield_value=2, increment=2, entryfield_validate={'validator': 'integer', 'min': 2, 'max': 12}) ct.pack() cb = ComboBox(top, labelpos=W, lael_text='Type:') for animal in ('dog', 'cat', 'hamster', 'python'): cb.insert(end, animal) cp.pack() qb = Button(top, text='QUIT', command=top.quit, bg='red', fg='white') qb.back() top.mainloop()