def __init__(self, parent: Widget, chart_manager, color): PairSelector.__init__(self, parent, chart_manager, color) self.pair_var = StringVar() self.menubutton = Menubutton( self, textvariable=self.pair_var, font=Fonts.FIXED_14, width=7, background=color, foreground=color.contrast, bd=0, pady=6, ) self.menu = Menu( self.menubutton, background=color, foreground=color.contrast, font=Fonts.FIXED_14, tearoff=False, ) self.menubutton["menu"] = self.menu for pair in Pair.iter_pairs(): self.menu.add_command(label=pair.camel(), command=partial(self.pair_callback, pair)) if pair in self.SEPARATOR_AFTER: self.menu.add_separator() grid(self.menubutton, 0, 0)
def __init__(self, parent: Widget, chart_manager, color): QuoteKindSelector.__init__(self, parent, chart_manager, color) self.quote_kind_var = StringVar() self.menubutton = Menubutton( self, textvariable=self.quote_kind_var, font=Fonts.FIXED_14, width=4, background=color, foreground=color.contrast, bd=0, pady=6, ) self.menu = Menu( self.menubutton, background=color, foreground=color.contrast, font=Fonts.FIXED_14, tearoff=False, ) self.menubutton["menu"] = self.menu self.menu.add_command( label=QuoteKind.ASK.name, command=partial(self.quote_kind_callback, QuoteKind.ASK), ) self.menu.add_command( label=QuoteKind.MID.name, command=partial(self.quote_kind_callback, QuoteKind.MID), ) self.menu.add_command( label=QuoteKind.BID.name, command=partial(self.quote_kind_callback, QuoteKind.BID), ) grid(self.menubutton, 0, 0)
def __init__(self, parent, ledger, entry, **kwargs): self.entry = entry # Current entry for which this menu is created self.ledger = ledger self.tv = kwargs['textvariable'] Menubutton.__init__(self, parent, **kwargs) self.refresh()
class mgcombocheckboxes: def __init__(self, topwin, itemkeyval): self.parentframe = topwin self.mb = Menubutton(topwin, text="CheckComboBox", relief=RAISED) self.mb.grid() self.mb.menu = Menu(self.mb, tearoff=0) self.mb["menu"] = self.mb.menu # #self.mb.menu["menu"] = self.mb.menu self.itemischecked = {} self.comboitemcount = 0 for menuentry in itemkeyval: itemvar = IntVar() itemvar.set(itemkeyval[menuentry]) # a keyvalue pair with menu item name and an itemvar unique to that selection self.itemischecked[menuentry] = itemvar self.mb.menu.add_checkbutton(label=menuentry, variable=itemvar) self.comboitemcount += 1 #self.mb.config(menu=self.mb.menu) def grid(self, row, column): #self.mb.grid(row=5, column=7) pass #return the KV pairs of the combobuttons true/false checked or not def mgcombochecks_get(self): return self.itemischecked def mgcombochecks_add(self, itemstr): itemvar = IntVar() itemvar.set(False) # a keyvalue pair with menu item name and an itemvar unique to that selection self.itemischecked[itemstr] = itemvar self.mb.menu.add_checkbutton(label=itemstr, variable=itemvar) self.comboitemcount += 1
def __init__(self): master = Tk() master.title('Text Editor', ) master.geometry('750x500') master.resizable(0, 0) back = tk.Frame(master=master, bg='gray') back.pack_propagate(0) back.pack(fill='both', expand = True) txt_box = Text(master=back, bg='pale green', fg='black', font=('Helvetica', '12')) txt_box.place(height='480', width='750', x='0', y='30') file_name = Text(master=back, bg='white') file_name.place(x='110', y='5', height='20', width='150') file_btn = Menubutton(master=back, bg='gray', text='File') file_btn.menu = Menu(file_btn) file_btn['menu'] = file_btn.menu file_btn.menu.add_command(label='Open', command=lambda: open_file(file_name, txt_box)) file_btn.place(x='0', y='0', height='30', width='50') save_btn = Menubutton(master=back, bg='gray', text='Save') save_btn.menu = Menu(save_btn) save_btn['menu'] = save_btn.menu save_btn.menu.add_command(label='Save', command=lambda: save_file(file_name, txt_box)) save_btn.place(x='50.5', y='0', height='30', width='50') master.mainloop()
def __init__(self, parent: Widget, chart_manager, color): GranSelector.__init__(self, parent, chart_manager, color) self.gran_var = StringVar() self.menubutton = Menubutton( self, textvariable=self.gran_var, font=Fonts.FIXED_14, width=10, background=color, foreground=color.contrast, bd=0, pady=6, ) self.menu = Menu( self.menubutton, background=color, foreground=color.contrast, font=Fonts.FIXED_14, tearoff=False, ) self.menubutton["menu"] = self.menu for item in self.MENU_LAYOUT: if item is None: self.menu.add_separator() else: self.menu.add_command( label=item.name, command=partial(self.gran_callback, item) ) grid(self.menubutton, 0, 0)
def task_list(self): fr = Frame(self) fr_top = Frame(fr) task_lbx = Listbox(fr_top) task_lbx.pack(anchor="center", fill="both", expand=True, padx=3, pady=3) self._task_box = task_lbx fr_bot = Frame(fr, height='2') b1 = Menubutton(fr_bot, text='실행메뉴') b1.menu = Menu(b1, tearoff=0) b1['menu'] = b1.menu b1.menu.add_command(label='실행', command=self.convert) b1.menu.add_command(label='비우기', command=self.delete_task_item) b1.pack() fr_top.pack(side='top', fill='both', expand=True) fr_bot.pack(side='bottom', fill='x') task_lbx.config(highlightcolor='green', font=('굴림체', 10), activestyle='none', selectmode='extended') self.task_lbx = task_lbx return fr
def create_pull_down_menu(self): mb = Menubutton(self.master, text='Select API.', relief=RAISED) mb.grid() mb.menu = Menu(mb, tearoff=0) mb['menu'] = mb.menu var1 = IntVar() var2 = IntVar() var3 = IntVar() mb.menu.add_checkbutton(label="") return
def __init__(self, master,inimage=None, outimage=None): self.master = master self.inI = PhotoImage(file='%s' % inimage) self.outI = PhotoImage(file='%s' % outimage) Menubutton.__init__(self, master, image=self.outI) self.configure(relief='flat', bd=0) self.bind('<Any-Enter>', lambda e, state=1, s=self: s.change(e, state)) self.bind('<Any-Leave>', lambda e, state=0, s=self: s.change(e, state)) self.menu = Menu(self, tearoff=0) self["menu"] = self.menu
class PairMenu(PairSelector): def __init__(self, parent: Widget, chart_manager, color): PairSelector.__init__(self, parent, chart_manager, color) self.pair_var = StringVar() self.menubutton = Menubutton( self, textvariable=self.pair_var, font=Fonts.FIXED_14, width=7, background=color, foreground=color.contrast, bd=0, pady=6, ) self.menu = Menu( self.menubutton, background=color, foreground=color.contrast, font=Fonts.FIXED_14, tearoff=False, ) self.menubutton["menu"] = self.menu for pair in Pair.iter_pairs(): self.menu.add_command(label=pair.camel(), command=partial(self.pair_callback, pair)) if pair in self.SEPARATOR_AFTER: self.menu.add_separator() grid(self.menubutton, 0, 0) def set_pair(self, pair: Optional[Pair]): if pair is None: self.pair_var.set("pair") self.menubutton.config(foreground="grey") else: self.pair_var.set(pair.camel()) self.menubutton.config(foreground=self.color.contrast) def pair_callback(self, pair: Pair): self.apply_pair(pair) SEPARATOR_AFTER = { Pair.EUR_JPY, Pair.GBP_JPY, Pair.AUD_JPY, Pair.NZD_JPY, Pair.USD_JPY, Pair.CAD_JPY, }
def toc_menu(self, text): "Create table of contents as drop-down menu." toc = Menubutton(self, text='TOC') drop = Menu(toc, tearoff=False) for lbl, dex in text.parser.toc: drop.add_command(label=lbl, command=lambda dex=dex:text.yview(dex)) toc['menu'] = drop return toc
class QuoteKindMenu(QuoteKindSelector): def __init__(self, parent: Widget, chart_manager, color): QuoteKindSelector.__init__(self, parent, chart_manager, color) self.quote_kind_var = StringVar() self.menubutton = Menubutton( self, textvariable=self.quote_kind_var, font=Fonts.FIXED_14, width=4, background=color, foreground=color.contrast, bd=0, pady=6, ) self.menu = Menu( self.menubutton, background=color, foreground=color.contrast, font=Fonts.FIXED_14, tearoff=False, ) self.menubutton["menu"] = self.menu self.menu.add_command( label=QuoteKind.ASK.name, command=partial(self.quote_kind_callback, QuoteKind.ASK), ) self.menu.add_command( label=QuoteKind.MID.name, command=partial(self.quote_kind_callback, QuoteKind.MID), ) self.menu.add_command( label=QuoteKind.BID.name, command=partial(self.quote_kind_callback, QuoteKind.BID), ) grid(self.menubutton, 0, 0) def set_quote_kind(self, quote_kind: Optional[QuoteKind]): if not quote_kind: self.quote_kind_var.set("amb") self.menubutton.config(foreground="grey") else: self.quote_kind_var.set(quote_kind) self.menubutton.config(foreground=self.color.contrast) def quote_kind_callback(self, quote_kind: QuoteKind): self.apply_quote_kind(quote_kind)
def __init__(self, topwin, itemkeyval): self.parentframe = topwin self.mb = Menubutton(topwin, text="CheckComboBox", relief=RAISED) self.mb.grid() self.mb.menu = Menu(self.mb, tearoff=0) self.mb["menu"] = self.mb.menu # #self.mb.menu["menu"] = self.mb.menu self.itemischecked = {} self.comboitemcount = 0 for menuentry in itemkeyval: itemvar = IntVar() itemvar.set(itemkeyval[menuentry]) # a keyvalue pair with menu item name and an itemvar unique to that selection self.itemischecked[menuentry] = itemvar self.mb.menu.add_checkbutton(label=menuentry, variable=itemvar) self.comboitemcount += 1
def inicializar_gui(self): lbl_titulo = Label(self.master, text='Lenguajes programación', font='31') lbl_titulo.pack() mbn_lenguajes = Menubutton(self.master, text='Menú lenguajes') mbn_lenguajes.menu = Menu(mbn_lenguajes) mbn_lenguajes['menu'] = mbn_lenguajes.menu var_javascript = IntVar() var_python = IntVar() var_java = IntVar() mbn_lenguajes.menu.add_command(label = 'JavaScript', command=self.mostrar_mensaje) mbn_lenguajes.menu.add_command(label = 'Python', command=self.mostrar_mensaje) mbn_lenguajes.menu.add_command(label = 'Java', command=self.mostrar_mensaje) mbn_lenguajes.pack()
def __init__( self, parent: Widget, string_var: StringVar, names: List[str], *args, **kwargs ): """Parent widget and string var are required. Args: parent: parent frame menubutton belongs to string_var: must be set a name in Images. names: all must be names of Images to select from. """ Menubutton.__init__(self, parent, *args, **kwargs) self.__string_var = string_var self.__string_var.trace("w", self.__trace_callback) value = string_var.get() self.config(image=Images[value]) menu = Menu(self) self["menu"] = menu for name in names: image = Images[name] callback = partial(self.__select_callback, name) menu.add_command(image=image, command=callback)
def component_list(self): #sandy brown fr1 = Frame(self) scrollbar = Scrollbar(fr1) scrollbar.pack(side="right", fill="y") self._list = Listbox(fr1, bg="dim grey", fg="white", width=20, yscrollcommand=scrollbar.set) mb1 = Menubutton(fr1, text='선택메뉴', relief='flat', bg='steel blue3') mb1.menu = Menu(mb1, tearoff=0) mb1['menu'] = mb1.menu mb1.menu.add_command(label='등록', command=self.choose_all) mb1.pack(side='bottom') mb1.menu.add_command(label='선택', command=lambda: self._list.select_set(0, END)) mb1.menu.add_command( label='해제', command=lambda: self._list.selection_clear(0, 'end')) self._list.pack(anchor="center", fill="both", expand=True, padx=3, pady=3) scrollbar.config(command=self._list.yview) self._list.config(highlightcolor='green', font=('나눔고딕', 10), activestyle='none', selectmode='extended') self._list.bind('<<ListboxSelect>>', self.select_item) self._list.bind('<Button-3>', self.sub_menu1) self._list.exportselection = 0 return fr1
def menuHelp(self): "Set menu with help information" hbutton = Menubutton(self.bar, text='Help', underline=0) hbutton.grid(row=0, column=2, sticky='w') menu = Menu(hbutton, tearoff=0) menu.add_command(label='Keys (F1)', command=lambda: msg.showinfo("Keys", KEYS)) menu.add_command(label='About', command=lambda: msg.showinfo("About", ABOUT)) hbutton.configure(menu=menu)
def menuTag(self): "Set menu for working with tags" fbutton = Menubutton(self.bar, text='Tags', underline=0) fbutton.grid(row=0, column=1, sticky='w') menu = Menu(fbutton, tearoff=0) menu.add_command(label='Search... (/)', command=lambda: self.openSearch(1)) menu.add_command(label='Edit ([)', command=lambda: self.panel[self.src].tagEdit(1)) menu.add_command(label="Don't save (Esc)", command=lambda: self.panel[self.src].tagExit(1)) menu.add_command(label='Correct DB', command=lambda: self.fo.correctDb()) fbutton.configure(menu=menu)
def menuFile(self): "Set menu for file commands" cbutton = Menubutton(self.bar, text='Files', underline=0) cbutton.grid(row=0, column=0, sticky='w') menu = Menu(cbutton, tearoff=0) menu.add_command(label='Rename (F2)', command=lambda: self.panel[self.src].rename(1)) menu.add_command(label='Copy (F5)', command=lambda: self.copy(1)) menu.add_command(label='Move (F6)', command=lambda: self.move(1)) menu.add_command(label='New folder (F7)', command=lambda: self.panel[self.src].newDir(1)) menu.add_command(label='Equal panels (=)', command=lambda: self.makeEqual(1)) menu.add_separator({}) menu.add_command(label='Quit (Ctrl+Q)', command=lambda: self.root.destroy()) cbutton.configure(menu=menu)
def _make_menu_bar(self): """ make menu bar at the top (TK9.0 menus below) expand=no, fill=X so same width on resize """ menu_bar = Frame(self, relief=RAISED, bd=2) menu_bar.pack(side=TOP, fill=X) for (name, key, items) in self.menu_bar: mbutton = Menubutton(menu_bar, text=name, underline=key) mbutton.pack(side=LEFT) pulldown = Menu(mbutton) self._add_menu_items(pulldown, items) mbutton.config(menu=pulldown) if self.help_button: Button(menu_bar, text='Help', cursor='gumby', relief=FLAT, command=self.help).pack(side=RIGHT)
def createInterface(self): # Handle to the toplevels interior interior = self.interior() menuBar = self.menuBar self.menuBar.destroy() # Create a frame to hold all stuff mainFrame = Frame(interior) self.listZone = Pmw.Group(mainFrame, tag_pyclass=None) self.listZone.pack(expand=0, fill=tkinter.X, padx=3, pady=3) listFrame = self.listZone.interior() self.lightEntry = self.createcomponent( 'Lights List', (), None, Pmw.ComboBox, (listFrame, ), label_text='Light :', labelpos=tkinter.W, entry_width=25, selectioncommand=self.selectLight, scrolledlist_items=self.lightList) self.lightEntry.pack(side=tkinter.LEFT) self.renameButton = self.createcomponent('Rename Light', (), None, Button, (listFrame, ), text=' Rename ', command=self.renameLight) self.renameButton.pack(side=tkinter.LEFT) self.addLighZone = Pmw.Group(listFrame, tag_pyclass=None) self.addLighZone.pack(side=tkinter.LEFT) insideFrame = self.addLighZone.interior() self.lightsButton = Menubutton(insideFrame, text='Add light', borderwidth=3, activebackground='#909090') lightsMenu = Menu(self.lightsButton) lightsMenu.add_command(label='Add Ambient Light', command=self.addAmbient) lightsMenu.add_command(label='Add Directional Light', command=self.addDirectional) lightsMenu.add_command(label='Add Point Light', command=self.addPoint) lightsMenu.add_command(label='Add Spotlight', command=self.addSpot) self.lightsButton.pack(expand=0) self.lightsButton['menu'] = lightsMenu self.deleteButton = self.createcomponent('delete Light', (), None, Button, (listFrame, ), text=' Delete ', command=self.deleteLight) self.deleteButton.pack(side=tkinter.LEFT) self.lightColor = seColorEntry(mainFrame, text='Light Color', value=self.lightColor) self.lightColor['command'] = self.setLightingColorVec self.lightColor['resetValue'] = [0.3 * 255, 0.3 * 255, 0.3 * 255, 0] self.lightColor.pack(fill=tkinter.X, expand=0) self.bind(self.lightColor, 'Set light color') # Notebook pages for light specific controls self.lightNotebook = Pmw.NoteBook(mainFrame, tabpos=None, borderwidth=0) ambientPage = self.lightNotebook.add('Ambient') directionalPage = self.lightNotebook.add('Directional') pointPage = self.lightNotebook.add('Point') spotPage = self.lightNotebook.add('Spot') # Put this here so it isn't called right away self.lightNotebook['raisecommand'] = self.updateLightInfo # Directional light controls self.dSpecularColor = seColorEntry(directionalPage, text='Specular Color') self.dSpecularColor['command'] = self.setSpecularColor self.dSpecularColor.pack(fill=tkinter.X, expand=0) self.bind(self.dSpecularColor, 'Set directional light specular color') self.dPosition = Vector3Entry(directionalPage, text='Position') self.dPosition['command'] = self.setPosition self.dPosition['resetValue'] = [0, 0, 0, 0] self.dPosition.pack(fill=tkinter.X, expand=0) self.bind(self.dPosition, 'Set directional light position') self.dOrientation = Vector3Entry(directionalPage, text='Orientation') self.dOrientation['command'] = self.setOrientation self.dOrientation['resetValue'] = [0, 0, 0, 0] self.dOrientation.pack(fill=tkinter.X, expand=0) self.bind(self.dOrientation, 'Set directional light orientation') # Point light controls self.pSpecularColor = seColorEntry(pointPage, text='Specular Color') self.pSpecularColor['command'] = self.setSpecularColor self.pSpecularColor.pack(fill=tkinter.X, expand=0) self.bind(self.pSpecularColor, 'Set point light specular color') self.pPosition = Vector3Entry(pointPage, text='Position') self.pPosition['command'] = self.setPosition self.pPosition['resetValue'] = [0, 0, 0, 0] self.pPosition.pack(fill=tkinter.X, expand=0) self.bind(self.pPosition, 'Set point light position') self.pConstantAttenuation = Slider(pointPage, text='Constant Attenuation', max=1.0, resolution=0.01, value=1.0) self.pConstantAttenuation['command'] = self.setConstantAttenuation self.pConstantAttenuation.pack(fill=tkinter.X, expand=0) self.bind(self.pConstantAttenuation, 'Set point light constant attenuation') self.pLinearAttenuation = Slider(pointPage, text='Linear Attenuation', max=1.0, resolution=0.01, value=0.0) self.pLinearAttenuation['command'] = self.setLinearAttenuation self.pLinearAttenuation.pack(fill=tkinter.X, expand=0) self.bind(self.pLinearAttenuation, 'Set point light linear attenuation') self.pQuadraticAttenuation = Slider(pointPage, text='Quadratic Attenuation', max=1.0, resolution=0.01, value=0.0) self.pQuadraticAttenuation['command'] = self.setQuadraticAttenuation self.pQuadraticAttenuation.pack(fill=tkinter.X, expand=0) self.bind(self.pQuadraticAttenuation, 'Set point light quadratic attenuation') # Spot light controls self.sSpecularColor = seColorEntry(spotPage, text='Specular Color') self.sSpecularColor['command'] = self.setSpecularColor self.sSpecularColor.pack(fill=tkinter.X, expand=0) self.bind(self.sSpecularColor, 'Set spot light specular color') self.sConstantAttenuation = Slider(spotPage, text='Constant Attenuation', max=1.0, resolution=0.01, value=1.0) self.sConstantAttenuation['command'] = self.setConstantAttenuation self.sConstantAttenuation.pack(fill=tkinter.X, expand=0) self.bind(self.sConstantAttenuation, 'Set spot light constant attenuation') self.sLinearAttenuation = Slider(spotPage, text='Linear Attenuation', max=1.0, resolution=0.01, value=0.0) self.sLinearAttenuation['command'] = self.setLinearAttenuation self.sLinearAttenuation.pack(fill=tkinter.X, expand=0) self.bind(self.sLinearAttenuation, 'Set spot light linear attenuation') self.sQuadraticAttenuation = Slider(spotPage, text='Quadratic Attenuation', max=1.0, resolution=0.01, value=0.0) self.sQuadraticAttenuation['command'] = self.setQuadraticAttenuation self.sQuadraticAttenuation.pack(fill=tkinter.X, expand=0) self.bind(self.sQuadraticAttenuation, 'Set spot light quadratic attenuation') self.sExponent = Slider(spotPage, text='Exponent', max=1.0, resolution=0.01, value=0.0) self.sExponent['command'] = self.setExponent self.sExponent.pack(fill=tkinter.X, expand=0) self.bind(self.sExponent, 'Set spot light exponent') # MRM: Add frustum controls self.lightNotebook.setnaturalsize() self.lightNotebook.pack(expand=1, fill=tkinter.BOTH) mainFrame.pack(expand=1, fill=tkinter.BOTH)
def __init__(self, client): Tk.__init__(self) self.client = client self.programPanel = ProgramPanel(client) self.programPanel.grid(row = 0, column = 0, sticky = NSEW) self.frame = Frame(self) self.frame.grid(row = 0, column = 0, sticky = NSEW) nextRow = Counter() # Create the menu. menu = Frame(self.frame) addButton = Menubutton(menu, text = 'Add') addButton.pack() menu.grid(row = nextRow(), column = 0, sticky = W) # Create the program panel. self.program = ProgramWidget(self.frame, client) self.program.grid(row = nextRow(), column = 0, columnspan = 2, sticky = W) label = Label(self.frame, text = 'AWB') label.grid(row = nextRow(), column = 0) self.recordMode = Button(self.frame, text = 'P', command = self.toggleRecord) modeRow = nextRow() self.recordMode.grid(row = modeRow, column = 0, sticky = W) self.status = Label(self.frame, text = 'Idle') self.status.grid(row = modeRow, column = 1) self.channels = [] self.channelFrame = Frame(self.frame) self.channelFrame.grid(row = nextRow(), columnspan = 2) self.bind('q', self.terminate) self.bind('f', self.foo) self.bind('r', self.toggleRecord) self.bind('k', self.toggleSticky) self.bind('.', self.nextSection) self.bind(',', self.prevSection) self.bind('<space>', self.togglePause) self.bind('K', self.clearAllState) self.protocol('WM_DELETE_WINDOW', self.destroy) self.bind('<F1>', lambda evt: self.frame.tkraise()) self.bind('<F2>', lambda evt: self.programPanel.tkraise()) for i in range(0, 8): # Bind number key. self.bind(str(i), lambda evt, channel = i: self.toggleChannel(channel) ) # Create channel channel = Channel(self.channelFrame, i) self.channels.append(channel) channel.pack(side = LEFT) client.addChannelSubscriber( i, lambda ch, status, channel = channel: channel.changeStatus(status) )
def make_file_type_menu(self, menubar): _, e = os.path.splitext(self.file) ext = e[1:] if ext == "py": pybtn = Menubutton(menubar, text='Python', name=ext) pybtn.pack(side=LEFT) py = Menu(pybtn, tearoff=0) py.add_command(label='Compile', command=self.compile_python, accelerator="Ctrl+F5") py.add_command(label='Run', command=self.run_python, accelerator="F5") pybtn.config(menu=py) self.bind_all("<Control-F5>", self.compile_python) self.bind_all("<F5>", self.run_python) elif ext == "tcl": tclbtn = Menubutton(menubar, text='TCL', name=ext) tclbtn.pack(side=LEFT) tcl = Menu(tclbtn, tearoff=0) tcl.add_command(label='Run', command=self.run_tcl, accelerator="F5") tclbtn.config(menu=tcl) self.bind_all("<F5>", self.run_tcl)
def make_menu(self): self.menubar = Frame(self) self.menubar.pack(side=TOP) filebtn = Menubutton(self.menubar, text='File') filebtn.pack(side=LEFT) file = Menu(filebtn, tearoff=0) file.add_command(label='New', command=self.new, accelerator="Ctrl+N") file.add_command(label='Save', command=self.save, accelerator="Ctrl+S") file.add_command(label='Quit', command=self.quit, accelerator="Ctrl+Q") filebtn.config(menu=file) editbtn = Menubutton(self.menubar, text='Edit') editbtn.pack(side=LEFT) edit = Menu(editbtn, tearoff=0) edit.add_command(label='Cut', command=self.cut) edit.add_command(label='Copy', command=self.copy) edit.add_command(label='Paste', command=self.paste) editbtn.config(menu=edit) if self.file: self.make_file_type_menu(self.menubar)
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) self.configuration = Configuration().load_configuration() self.api = WalletAPI() self.tokens = self.api.list_tokens(self.configuration) self.eth_balance, _ = self.api.get_balance(self.configuration) def change_token(token): if token == 'ETH': self.eth_balance, _ = self.api.get_balance(self.configuration) else: self.eth_balance, _ = self.api.get_balance(self.configuration, token) balance.set(str(self.eth_balance) + ' ' + token) token_symbol = StringVar() token_symbol.set('ETH') balance = StringVar() balance.set(str(self.eth_balance) + ' ' + token_symbol.get()) mb = Menubutton(self, width=60, textvariable=token_symbol, relief=RAISED) mb.grid() mb.menu = Menu(mb, tearoff=0) mb["menu"] = mb.menu mb.menu.add_radiobutton(label="ETH", variable=token_symbol, value='ETH', command=lambda: change_token(token_symbol.get())) for token in self.tokens: mb.menu.add_radiobutton(label=token, variable=token_symbol, value=token, command=lambda: change_token(token_symbol.get())) mb.pack() label = Label(self, textvariable=balance, width=60, font=(None, 30)) label.pack() lbl_address = Label(self, text="To address:", width=60, font=(None, 20)) lbl_address.pack() entry_address = Entry(self, font=(None, 20), width=60, justify=CENTER) entry_address.pack() lbl_amount = Label(self, text="Amount:", width=60, font=(None, 20)) lbl_amount.pack() entry_amount = Entry(self, font=(None, 20), width=60, justify=CENTER) entry_amount.pack() lbl_passphrase = Label(self, text="Passphrase:", width=60, font=(None, 20)) lbl_passphrase.pack() entry_passphrase = Entry(self, font=(None, 20), width=60, justify=CENTER) entry_passphrase.pack() btn_send = Button(self, text="Send", width=60, font=(None, 16), command=lambda: self.send_transaction(entry_address.get(), entry_amount.get(), entry_passphrase.get(), token_symbol.get())) btn_send.pack() btn_back = Button(self, text="Back", width=60, font=(None, 16), command=self.navigate_home_page) btn_back.pack()
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) self.configuration = Configuration().load_configuration() self.api = WalletAPI() self.tokens = self.api.list_tokens(self.configuration) self.eth_balance, self.address = self.api.get_balance(self.configuration) def refresh(): change_token(token_symbol.get()) def change_token(token): if token == 'ETH': self.eth_balance, self.address = self.api.get_balance(self.configuration) else: self.eth_balance, self.address = self.api.get_balance(self.configuration, token) balance.set(str(self.eth_balance) + ' ' + token) token_symbol = StringVar() token_symbol.set('ETH') balance = StringVar() balance.set(str(self.eth_balance) + ' ' + token_symbol.get()) mb = Menubutton(self, width=60, textvariable=token_symbol, relief=RAISED) mb.grid() mb.menu = Menu(mb, tearoff=0) mb["menu"] = mb.menu mb.menu.add_radiobutton(label="ETH", variable=token_symbol, value='ETH', command=lambda: change_token(token_symbol.get())) for token in self.tokens: mb.menu.add_radiobutton(label=token, variable=token_symbol, value=token, command=lambda: change_token(token_symbol.get())) mb.menu.add_radiobutton(label="Add new token ...", command=self.navigate_add_token_page) mb.pack() label_address_lbl = Label(self, text='Address:', width=60, font=(None, 10, "bold")) label_address_lbl.pack() label_address = Label(self, text=self.address, width=60, font=(None, 10)) label_address.pack() label_balance = Label(self, textvariable=balance, width=60, font=(None, 30)) label_balance.pack() btn_refresh = Button(self, text="Refresh", command=refresh, width=60, font=(None, 16)) btn_refresh.pack() btn_copy_address = Button(self, text="Copy address", command=self.copy_address, width=60, font=(None, 16)) btn_copy_address.pack() btn_send_transaction = Button(self, text="Send Transaction", command=self.navigate_transaction_page, width=60, font=(None, 16)) btn_send_transaction.pack()
""" Menubutton example """ from tkinter import Tk, Menubutton, Menu from tkinter import RAISED root = Tk() mbutton = Menubutton(root, text='Food') # the pull-down stands alone picks = Menu(mbutton) mbutton.config(menu=picks) picks.add_command(label='spam', command=root.quit) picks.add_command(label='eggs', command=root.quit) picks.add_command(label='bacon', command=root.quit) mbutton.pack() mbutton.config(bg='white', bd=4, relief=RAISED) root.mainloop()
def gui_main(): funktsioonid=[] fun_label = '---Kasutuses---' def fun1(): funktsioonid.append("f1") menüü.menu.entryconfig(1, label=fun_label) menüü2.menu.entryconfig(1, label=fun_label) menüü3.menu.entryconfig(1, label=fun_label) return funktsioonid def fun2(): funktsioonid.append("f2") menüü.menu.entryconfig(2, label=fun_label) menüü2.menu.entryconfig(2, label=fun_label) menüü3.menu.entryconfig(2, label=fun_label) return funktsioonid def fun3(): funktsioonid.append("f3") menüü.menu.entryconfig(3, label=fun_label) menüü2.menu.entryconfig(3, label=fun_label) menüü3.menu.entryconfig(3, label=fun_label) def fun4(): funktsioonid.append("f4") menüü.menu.entryconfig(4, label=fun_label) menüü2.menu.entryconfig(4, label=fun_label) menüü3.menu.entryconfig(4, label=fun_label) def fun5(): funktsioonid.append("f5") menüü.menu.entryconfig(5, label=fun_label) menüü2.menu.entryconfig(5, label=fun_label) menüü3.menu.entryconfig(5, label=fun_label) def menüülist(menüü): menüü.menu.add_command(label="Paneb heleduse maksimumile",command=fun1, activebackground="gray30", activeforeground="snow2") menüü.menu.add_command(label="Paneb heleduse miinimumile",command=fun2, activebackground="gray30", activeforeground="snow2") ## menüü.menu.add_command(label="Funktsioon 3",command=fun3, activebackground="gray30", activeforeground="snow2") ## menüü.menu.add_command(label="Funktsioon 4",command=fun4, activebackground="gray30", activeforeground="snow2") ## menüü.menu.add_command(label="Funktsioon 5",command=fun5, activebackground="gray30", activeforeground="snow2") raam = Tk() raam.title("Kasutajaliides") pealkiri=ttk.Label(raam, text="Palun vali igale liigutusele vastav funktsioon (esimene valik loeb): ") pealkiri.grid(column=1, row=0, padx=10, pady=10, sticky=(N,S,W,E)) silt1 = ttk.Label(raam, text="Üks sõrm püsti") silt1.grid(column=1, row=1, padx=10, pady=10, sticky=(E)) silt2 = ttk.Label(raam, text="Kaks sõrme püsti") silt2.grid(column=1, row=2, padx=10, pady=10, sticky=(E)) #silt3 = ttk.Label(raam, text="Kolm sõrme püsti") #silt3.grid(column=1, row=3, padx=10, pady=10, sticky=(E)) menüü=Menubutton(raam, text="Vali funktsioon", textvariable="Funktsioon 1", bg="gray60", activebackground="gray30", activeforeground="snow2") menüü.menu = Menu(menüü) menüü["menu"]=menüü.menu menüülist(menüü) menüü2=Menubutton(raam, text="Vali funktsioon", bg="gray60", activebackground="gray30", activeforeground="snow2") menüü2.menu = Menu(menüü2) menüü2["menu"]=menüü2.menu menüülist(menüü2) menüü3=Menubutton(raam, text="Vali funktsioon", bg="gray60", activebackground="gray30", activeforeground="snow2") menüü3.menu = Menu(menüü3) menüü3["menu"]=menüü3.menu menüülist(menüü3) menüü.grid(column=2, row=1, padx=10, pady=10, sticky=(W)) menüü2.grid(column=2, row=2, padx=10, pady=10, sticky=(W)) #menüü3.grid(column=2, row=3, padx=10, pady=10, sticky=(W)) def suleaken(): raam.destroy() lõpeta=ttk.Button(raam, text="Salvesta", command=suleaken) lõpeta.grid(column=2, row=4, padx=10, pady=10, sticky=(N,S,W,E)) raam.columnconfigure(2,weight=1) raam.rowconfigure(2,weight=1) raam.mainloop() return funktsioonid
print("Python " + str(variablepython.get())) def toggleJavaFun(): print("Java " + str(variablejava.get())) def toggleRadio(): print("Radio : " + str(radio_val.get())) frame = Frame(window, relief=RAISED, borderwidth=1) frame.pack(fill=X) #First Menu first_menu = Menubutton(frame, text="File") first_menu.pack(padx=3, pady=3, side=LEFT) first_menu.menu = Menu(first_menu, tearoff=False) first_menu.menu.add_command(label="New", command=newFile) first_menu.menu.add_command(label="Open", command=openFile) first_menu.menu.add("separator") first_menu.menu.add_command(label="Exit", command=exitMenu) first_menu['menu'] = first_menu.menu #second Menu second_menu = Menubutton(frame, text="Edit") second_menu.pack(padx=3, pady=3, side=LEFT) second_menu.menu = Menu(second_menu, tearoff=False) second_menu.menu.add_command(label="DELETE ALL", command=delFile) second_menu.menu.add_command(label="CLOSE", command=closeFile) second_menu.menu.add("separator")
def ventanaPrincipal(): root=Tk() w= Frame(root) w.pack() bottomframe= Frame(root) bottomframe.pack(side=BOTTOM) mb1=Menubutton(bottomframe, text="Datos", relief=RAISED ) mb1.menu =Menu(mb1, tearoff = 0 ) mb1["menu"]=mb1.menu mb1.menu.add_command(label="Almacenar",command=fe.almacenarBD) mb1.menu.add_command(label="Listar",command=fp.list_bd) mb1.menu.add_command(label="Salir",command=root.destroy) mb1.grid(row=0,column=0) mb1=Menubutton(bottomframe, text="Buscar", relief=RAISED ) mb1.menu =Menu(mb1, tearoff = 0 ) mb1["menu"]=mb1.menu mb1.menu.add_command(label="Tema",command=fp.buscar_BD_Titulo) mb1.menu.add_command(label="Autor",command=fp.buscar_BD_Autor) mb1.menu.add_command(label="Fecha",command=fp.buscar_BD_Fecha) mb1.grid(row=0,column=1) mb1=Menubutton(bottomframe, text="Estadisticas", relief=RAISED ) mb1.menu =Menu(mb1, tearoff = 0 ) mb1["menu"]=mb1.menu mb1.menu.add_command(label="Temas mas populares",command=fp.popularesBD) mb1.menu.add_command(label="Temas mas activos",command=fp.activosBD) mb1.grid(row=0,column=2) #DESC root.mainloop()
def RoomAvailibity(): currentDate = datetime.datetime.now() currentDay = date.today() #current date for schedule nextDay1 = date.today() + datetime.timedelta(days=1) nextDay2 = date.today() + datetime.timedelta(days=2) nextDay3 = date.today() + datetime.timedelta(days=3) nextDay4 = date.today() + datetime.timedelta(days=4) nextDay5 = date.today() + datetime.timedelta(days=5) nextDay6 = date.today() + datetime.timedelta(days=6) nextDay7 = date.today() + datetime.timedelta(days=7) year = currentDate.year day = currentDate.day month = currentDate.month # root=Tk() # root.title("Key") # root.geometry("200x200+1000+100") c2window = Tk() c2window.title("Available rooms") c2window.geometry("1000x600+10+100") conn = sqlite3.connect('hotel.db') cur = conn.cursor() sql = ' SELECT * FROM Room' cur.execute(sql) getAll = cur.fetchall() print(getAll[0]) def checkIn(h): c2window.destroy() room(h) a = 99 for row in range(22): for column in range(9): if row == 0: #day of the week lable0 = Label(c2window, text="Room Number", bg="black", fg="white", padx=3, pady=3) lable0.grid(row=0, column=0, sticky="nsew", padx=1, pady=1) lable3 = Label(c2window, text=currentDay.strftime('%A'), bg="black", fg="white", padx=3, pady=3) lable3.grid(row=0, column=1, sticky="nsew", padx=1, pady=1) lable4 = Label(c2window, text=nextDay1.strftime('%A'), bg="black", fg="white", padx=3, pady=3) lable4.grid(row=0, column=2, sticky="nsew", padx=1, pady=1) lable3 = Label(c2window, text=nextDay2.strftime('%A'), bg="black", fg="white", padx=3, pady=3) lable3.grid(row=0, column=3, sticky="nsew", padx=1, pady=1) lable3 = Label(c2window, text=nextDay3.strftime('%A'), bg="black", fg="white", padx=3, pady=3) lable3.grid(row=0, column=4, sticky="nsew", padx=1, pady=1) lable3 = Label(c2window, text=nextDay4.strftime('%A'), bg="black", fg="white", padx=3, pady=3) lable3.grid(row=0, column=5, sticky="nsew", padx=1, pady=1) lable3 = Label(c2window, text=nextDay5.strftime('%A'), bg="black", fg="white", padx=3, pady=3) lable3.grid(row=0, column=6, sticky="nsew", padx=1, pady=1) lable3 = Label(c2window, text=nextDay6.strftime('%A'), bg="black", fg="white", padx=3, pady=3) lable3.grid(row=0, column=7, sticky="nsew", padx=1, pady=1) lable3 = Label(c2window, text=nextDay7.strftime('%A'), bg="black", fg="white", padx=3, pady=3) lable3.grid(row=0, column=8, sticky="nsew", padx=1, pady=1) elif row == 1: #date lable2 = Label(c2window, text=str(currentDay.month) + "/" + str(currentDay.day)) lable2.grid(row=1, column=1, sticky="nsew", padx=1, pady=1) lable2 = Label(c2window, text=str(nextDay1.month) + "/" + str(nextDay1.day)) lable2.grid(row=1, column=2, sticky="nsew", padx=1, pady=1) lable2 = Label(c2window, text=str(nextDay2.month) + "/" + str(nextDay2.day)) lable2.grid(row=1, column=3, sticky="nsew", padx=1, pady=1) lable2 = Label(c2window, text=str(nextDay3.month) + "/" + str(nextDay3.day)) lable2.grid(row=1, column=4, sticky="nsew", padx=1, pady=1) lable2 = Label(c2window, text=str(nextDay4.month) + "/" + str(nextDay4.day)) lable2.grid(row=1, column=5, sticky="nsew", padx=1, pady=1) lable2 = Label(c2window, text=str(nextDay5.month) + "/" + str(nextDay5.day)) lable2.grid(row=1, column=6, sticky="nsew", padx=1, pady=1) lable2 = Label(c2window, text=str(nextDay6.month) + "/" + str(nextDay6.day)) lable2.grid(row=1, column=7, sticky="nsew", padx=1, pady=1) lable2 = Label(c2window, text=str(nextDay7.month) + "/" + str(nextDay7.day)) lable2.grid(row=1, column=8, sticky="nsew", padx=1, pady=1) elif column == 0: a += 1 label = Label(c2window, text=a) label.grid(row=row, column=column, sticky="nsew", padx=1, pady=1) else: label6 = Menubutton(c2window, text="Available") label6.grid(row=row, column=column, sticky="nsew", padx=1, pady=1) c2window.grid_columnconfigure(column, weight=1, uniform=1) label6.menu = Menu(label6) label6["menu"] = label6.menu if column == 1: label6.menu.add_command( label="check In", command=lambda roomNumber=a: checkIn(roomNumber)) else: label6.menu.add_command( label="Reservation", command=lambda roomNumber=a: reservationSystem()) # lambda h = h ,row= row, column=column, l= label : availableRoom(row,column,h,l)) # label.menu.add_command (label = "Reservation", command=lambda h= h, row= row, column=column, l= label : occupiedRoom(row,column,h,l)) def loadCheckin(): conn = sqlite3.connect('hotel.db') cur = conn.cursor() sql = ' SELECT * FROM Room WHERE CheckIN = ' + str(1) cur.execute(sql) result = cur.fetchall() def loadrooms(row, column, first_name): widget = c2window.grid_slaves(row=row, column=column)[0] widget.configure(bg="blue", fg="white", text=first_name) for row in result: if row[2] == 'Unavailable/Occupied': cur = conn.cursor() # sql = 'SELECT first_name, last_name FROM guests WHERE guest_id=' + str(row[6]) # sql= 'SELECT CheckInDate , CheckOutDate from Room UNION ALL SELECT first_name, last_name from guests WHERE guest_id=' +str(row[6]) sql = 'SELECT RoomNumber,first_name, last_name, CheckInDate, CheckOutDate from guests INNER JOIN Room on Room.guestID = guests.guest_id' cur.execute(sql) guest = cur.fetchall() for row in guest: print(row) year1, month1, day1 = map(int, row[4].split('/')) d = date(year1, month1, day1) year, month, day = map(int, row[3].split('/')) c = date(year, month, day) days = (d - c).days cur = conn.cursor() # sql = 'SELECT first_name, last_name FROM guests WHERE guest_id=' + str(row[6]) # sql= 'SELECT CheckInDate , CheckOutDate from Room UNION ALL SELECT first_name, last_name from guests WHERE guest_id=' +str(row[6]) sql = 'SELECT RowX, ColumnY FROM RoomAvailability WHERE RoomNumber =' + row[ 0] cur.execute(sql) roomHere = cur.fetchall() print(days) if days == 0: loadrooms(roomHere[0][0], roomHere[0][1], row[1]) elif days == 1: loadrooms(roomHere[0][0], roomHere[0][1], row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 1, row[1]) elif days == 2: loadrooms(roomHere[0][0], roomHere[0][1], row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 1, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 2, row[1]) elif days == 3: loadrooms(roomHere[0][0], roomHere[0][1], row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 1, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 2, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 3, row[1]) elif days == 4: loadrooms(roomHere[0][0], roomHere[0][1], row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 1, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 2, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 3, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 4, row[1]) elif days == 5: loadrooms(roomHere[0][0], roomHere[0][1], row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 1, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 2, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 3, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 4, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 5, row[1]) elif days == 6: loadrooms(roomHere[0][0], roomHere[0][1], row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 1, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 2, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 3, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 4, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 5, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 6, row[1]) elif days == 7: loadrooms(roomHere[0][0], roomHere[0][1], row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 1, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 2, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 3, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 4, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 5, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 6, row[1]) loadrooms(roomHere[0][0], roomHere[0][1] + 7, row[1]) loadCheckin()