class ConfusionMatrixViewer(): def __init__(self, class_number, matrix, kappa): self.class_number = class_number self.matrix = matrix self.kappa = kappa self.child_window = Toplevel(height=800, width=1500) self.child_window.title('Verification of image classification') def run(self): confusion_matrix_table = ConfusionMatrixTable(self.child_window, self.class_number, self.matrix) confusion_matrix_table.pack(padx=5, pady=5) kappa_label = Label(self.child_window, font=BOLD_FONT, text='Kappa Coefficient: {0}'.format(self.kappa)) kappa_label.pack(anchor='w', padx=5) save_button = Button(self.child_window, text='Save Validation', relief='raised', width=30, command=self._save_validation) save_button.pack(anchor='center', padx=5, pady=5) def _save_validation(self): save_validation_results(self.child_window, self.matrix, self.kappa)
def __init__(self, class_number, matrix, kappa): self.class_number = class_number self.matrix = matrix self.kappa = kappa self.child_window = Toplevel(height=800, width=1500) self.child_window.title('Verification of image classification')
def __init__(self, width, height, x_min, x_max, y_min, y_max, title, parent=None): self.title = title if parent: self.parent = parent self.top = parent.getWindow(title) else: self.tk = Tk() self.tk.withdraw() self.top = Toplevel(self.tk) self.top.wm_title(title) self.top.protocol('WM_DELETE_WINDOW', self.top.destroy) self.window_width = width self.window_height = height self.canvas = Canvas(self.top, width=self.window_width, height=self.window_height, background="white") self.canvas.pack() self.x_scale = width / float( x_max - x_min) # multiply an input value by this to get pixels self.y_scale = height / float(y_max - y_min) self.x_min = x_min self.y_min = y_min self.x_max = x_max self.y_max = y_max
def __init__(self, master, title, prompt, x_name, y_name, var_type, x_default, y_default, *args, **kwargs): Toplevel.__init__(self, master, *args, **kwargs) self.title(title) #TODO: Can this be done in a smarter manner? self._x_var = var_type(self) self._y_var = var_type(self) self._x_var.set(x_default) self._y_var.set(y_default) self.canceled = True self.prompt_label = Label(self, text=prompt) self.prompt_label.grid(row=0, column=0, columnspan=2, pady=2) self.x_label = Label(self, text="{}:".format(x_name)) self.x_input = Entry(self, textvariable=self._x_var) self.y_label = Label(self, text="{}:".format(y_name)) self.y_input = Entry(self, textvariable=self._y_var) self.x_label.grid(row=1, column=0, pady=2) self.x_input.grid(row=1, column=1, pady=2) self.y_label.grid(row=2, column=0, pady=2) self.y_input.grid(row=2, column=1, pady=2) self.ok_button = Button(self, text="OK", command=self.ok, width=self.BUTTON_WIDTH) self.cancel_button = Button(self, text="Cancel", command=self.cancel, width=self.BUTTON_WIDTH) self.ok_button.grid(row=3, column=0, sticky="NS", padx=5, pady=2) self.cancel_button.grid(row=3, column=1, sticky="NS", padx=5, pady=2)
def __init__(self, root, shape): """ Initialize root tkinter window and master GUI window """ Toplevel.__init__(self, root, width=200, height=200) self.__shape = shape if shape is False: self.close() return self.title('Edit Attributes') # copies TAGS to avoid aliasing self.__available_attributes = TAGS[:] self.container = Frame(self) self.container.pack(side=TOP, fill=BOTH, expand=True) self.top_frame = None self.bottom_frame = None self.note_text = None self.attributes_list = None self.selected_list = None self.transient(root) logger.info('Creating top frame') self.create_top_frame() logger.info('Creating bottom frame') self.create_bottom_frame()
def message(msg): global mainWin sub = Toplevel(mainWin) sub.wm_title("BonjourBackground - %s" % msg) lab = Label(sub, text=msg) lab.pack(side="top", fill="both", expand=True, padx=50, pady=20) pass
def __init__(self, parent, process, x, y): Toplevel.__init__(self, parent) self.wm_overrideredirect(True) self.wm_geometry("+%d+%d" % (x+25,y+20)) label = Label(self, text="", justify='left', background='white', relief='solid', borderwidth=1, font=("times", "12", "normal")) label.pack(ipadx=20) tree = Treeview(label) tree["columns"] = ("value") tree.column("#0", minwidth=0, width=100) tree.column("#1", minwidth=0, width=100) tree.heading("#0", text="Name") tree.heading("#1", text="Value") for A, state in process.state.items(): if isinstance(A, Algorithm): tree.insert("", 0, iid=A, text=str(A), values=("",)) for key, val in state.items(): tree.insert(A, 0, text=key, values=(val,)) for key, val in process.state.items(): if not isinstance(key, Algorithm): tree.insert("", 0, text=key, values=(val,)) tree.insert("", 0, text="UID", values=(process.UID,)) tree.pack()
def preview_report(self, report_data, callback): self.report_dialog = Toplevel() self.report_dialog.title("Preview Report") Button(self.report_dialog, text="Send Report", command=callback).pack() self.text_boxes[report_data['text_box']] = ScrolledText( self.report_dialog) self.text_boxes[report_data['text_box']].pack()
def run(self): print "Creating animation server..." if os.path.exists(SOCKET_NAME): os.remove(SOCKET_NAME) self.server = Animator(AnimationRequestHandler, self.simulate) if not self.simulate: print "Starting animation server..." print "Animation server is running on socket {0}".format( SOCKET_NAME) #print "Quit the server with CONTROL-C." self.server.serve_forever() else: print "Starting simulation..." button_window = Toplevel() button_window.title('Button Input') img = PhotoImage(file="easy_button.gif") single_easy_button = Button(button_window, image=img) single_easy_button.pack() single_easy_button.bind( "<Button-1>", lambda e: server.processCommand(ButtonEvent.SINGLEPRESS)) double_easy_button = Button(button_window, text="double tap") double_easy_button.pack() double_easy_button.bind( "<Button-1>", lambda e: server.processCommand(ButtonEvent.DOUBLEPRESS)) mainloop()
def __init__(self, parent, title, menuItem='', filePath='', _htest=False): """Get menu entry and url/ local file location for Additional Help User selects a name for the Help resource and provides a web url or a local file as its source. The user can enter a url or browse for the file. _htest - bool, change box location when running htest """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.resizable(height=FALSE, width=FALSE) self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Cancel) self.parent = parent self.result = None self.CreateWidgets() self.menu.set(menuItem) self.path.set(filePath) self.withdraw() #hide while setting geometry #needs to be done here so that the winfo_reqwidth is valid self.update_idletasks() #centre dialog over parent. below parent if running htest. self.geometry("+%d+%d" % (parent.winfo_rootx() + (parent.winfo_width() / 2 - self.winfo_reqwidth() / 2), parent.winfo_rooty() + ((parent.winfo_height() / 2 - self.winfo_reqheight() / 2) if not _htest else 150))) self.deiconify() #geometry set, unhide self.bind('<Return>', self.Ok) self.wait_window()
def __init__(self, message, value=None): self._prevent_execution_with_timeouts() Toplevel.__init__(self, self._get_parent()) self._init_dialog() self._create_body(message, value) self._create_buttons() self._result = None
def instructions(self): """Open instructions window.""" # Instantiates separate Toplevel instruction window. instr_window = Toplevel(self.root) instr_window.geometry('550x575+25+25') instr_window.title('Instructions') instr_window.wm_iconbitmap(constants.ICO) instr_window.resizable(False, False) # Creatse Scrollbar and Frame for containing other widgets. instr_scroll = Scrollbar(instr_window) instr_scroll.pack(fill=Y, side="right") instr_frame = Frame(instr_window, bg='white') instr_frame.pack(fill=BOTH, side="left") # Adds instruction text from constants and adds image of Cinzano's diagram. instr = Text(instr_frame, width=65, height=40, padx=10, pady=5, bd=0, wrap="word") instr.insert("end", constants.INSTR) cdiagram_file = Image.open("./static/cinzano_diagram.PNG") cdiagram_file = cdiagram_file.resize((500, 450), Image.ANTIALIAS) self.cdiag = ImageTk.PhotoImage(cdiagram_file) instr.image_create("end", image=self.cdiag) instr.tag_add("top", "1.0", "4.10") instr.tag_config("top", font='Times 12 bold') instr.tag_add("body", "5.0", "19.20") instr.tag_config("body", font='Times 12') instr.insert("end", constants.CDIAG) instr.pack() instr_scroll.config(command=instr.yview)
def __init__(self, parent, title, text): """Show the given text in a scrollable window with a 'close' button """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.geometry("=%dx%d+%d+%d" % (625, 500, parent.winfo_rootx() + 10, parent.winfo_rooty() + 10)) #elguavas - config placeholders til config stuff completed self.bg = '#ffffff' self.fg = '#000000' self.CreateWidgets() self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Ok) self.parent = parent self.textView.focus_set() #key bindings for this dialog self.bind('<Return>',self.Ok) #dismiss dialog self.bind('<Escape>',self.Ok) #dismiss dialog self.textView.insert(0.0, text) self.textView.config(state=DISABLED) self.wait_window()
def __init__(self, parent, objectList): Toplevel.__init__(self, parent) self.protocol('WM_DELETE_WINDOW', self.destroy) self._objectList = objectList self._lb = Listbox(self, selectmode = SINGLE) self._lb.pack() self._buttons = PanedWindow(self) for i in objectList.getKeysInOrder(): self._lb.insert(END, i) addButton = Button(self._buttons, text="Add", command=self.onAdd) addButton.pack(side=LEFT) modifyButton = Button(self._buttons, text="Modify", command=self.onModify) modifyButton.pack(side=LEFT) deleteButton = Button(self._buttons, text="Delete", command=self.onDelete) deleteButton.pack(side=LEFT) cancelButton = Button(self._buttons, text="Cancel", command=self.onCancel) cancelButton.pack(side=RIGHT) self._buttons.pack(side=BOTTOM)
def __init__(self, master, title, text): Toplevel.__init__(self, master=master) self.title(title) fra = Frame(self) fra.grid(row=0, column=0, pady=5, padx=5) self.tx = Text(fra, width=130, height=20, wrap=WORD) scr = Scrollbar(fra, command=self.tx.yview) self.tx.configure(yscrollcommand=scr.set) self.tx.pack(side=LEFT) scr.pack(side=RIGHT, fill=Y) self.tx.bind('<Enter>', lambda e: self._bound_to_mousewheel(e, self.tx)) self.tx.bind('<Leave>', self._unbound_to_mousewheel) self.tx.insert(END, text) self.tx.configure(state='disabled') if platform == "darwin": button_font = Font(family='Arial', size=15) else: button_font = Font(font=Button()["font"]) closeTopolPrevB = Button(self, text='Exit', bg='red', command=self.destroy, font=button_font) closeTopolPrevB.grid(row=1, column=0, pady=5)
def __init__(self, list_=None, master=None, title=None): '''Must have master, title is optional, li is too.''' self.master = master if self.master is not None: self.top = Toplevel(self.master) else: return self.v = None if list_ is None or not isinstance(list_, list): self.list = [] else: self.list = list_[:] self.top.transient(self.master) self.top.grab_set() self.top.bind("<Return>", self._choose) self.top.bind("<Escape>", self._cancel) if title: self.top.title(title) lf = Frame(self.top) #Sets up the list. lf.pack(side=TOP) scroll_bar = Scrollbar(lf) scroll_bar.pack(side=RIGHT, fill=Y) self.lb = Listbox(lf, selectmode=SINGLE) self.lb.pack(side=LEFT, fill=Y) scroll_bar.config(command=self.lb.yview) self.lb.config(yscrollcommand=scroll_bar.set) self.list.sort() for item in self.list: self.lb.insert(END, item) #Inserts items into the list. bf = Frame(self.top) bf.pack(side=BOTTOM) Button(bf, text="Select", command=self._choose).pack(side=LEFT) Button(bf, text="New", command=self._new).pack(side=LEFT) Button(bf, text="Cancel", command=self._cancel).pack(side=LEFT)
def goto_date_gui(self): date_top = Toplevel() date_top.title("Enter date") date_top.resizable(0, 0) # Inputs for month/year goto_month = Label(date_top, text="Month:") goto_month.grid(row=0, column=0) m_entry = Entry(date_top) m_entry.grid(row=0, column=1) goto_year = Label(date_top, text="Year:") goto_year.grid(row=1, column=0) y_entry = Entry(date_top) y_entry.grid(row=1, column=1) def month_jump(): try: month = int(m_entry.get()) year = int(y_entry.get()) if 0 < month <= 12 and 1970 <= year < 5000: self.calendar.month = month - 1 self.calendar.year = year self.update_calendar() except: pass submit = Button(date_top, text="Submit", command=month_jump) submit.grid(column=0, columnspan=3)
def __init__(self, callback): self._callback = callback self._root = Toplevel() self._root.title('FlowEntry Trace') self._root.minsize(width=300, height=150) self._top_frame = Frame(self._root) self._top_frame.pack(side=TOP, fill=X, padx=10, pady=10) # The text labels label_entry_frame = Frame(self._top_frame) label_entry_frame.pack(side=TOP, anchor=W, pady=5) self._username_label = LabelEntry(label_entry_frame, 'username') self._password_label = LabelEntry(label_entry_frame, 'password') # the buttons button_frame = Frame(self._top_frame, pady=5) button_frame.pack(side=BOTTOM, anchor=S) buttons_dict = OrderedDict([('ok', self._ok_callback), ('cancel', self._cancel_callback)]) Buttons(button_frame, buttons_dict, button_orientation=LEFT) # Hide this window until its needed self._root.withdraw()
def __init__( self ): """ Initialize window settings """ Toplevel.__init__( self ) self.title( "Help" ) self.iconbitmap( ICON_FILENAME ) self.geometry( "+100+50" ) help_list = { "0-9": "Save Image", "<-": "Prev", "->": "Next", "g": "Grayscale", "m": "Mirror", "i": "Invert", "b": "Blur", "c": "Contour", "d": "Detail", "e": "Edge Enhance", "Shift e": "Edge Enhance More", "o": "Emboss", "h": "Find Edges", "s": "Smooth", "Shift s": "Smooth More", "p": "Sharpen", "Shift c": "Clear All Effects", } CTRL_hl = { "CTRL <-": "Rotate CCW", "CTRL ->": "Rotate CW", "CTRL q": "Exit", "CTRL t": "Toss" } i = 0 for item in help_list: Label( self, text=help_list[ item ] ).grid( row=i, column=0, sticky="W" ) Label( self, text=item ).grid( row=i, column=1, sticky="W" ) i += 1 Label( self, text="----------------------------" ).grid( row=i, column=0, columnspan=2 ) i += 1 for item in CTRL_hl: Label( self, text=CTRL_hl[ item ] ).grid( row=i, column=0, sticky="W" ) Label( self, text=item ).grid( row=i, column=1, sticky="W" ) i += 1 Button( self, text="Ok", command=self.quit, width=7 ).grid( row=i, columnspan=2 ) self.mainloop() self.destroy()
def __init__(self, master, mixer): Toplevel.__init__(self, master, width=400) mixer_frame = MixerFrame(self, mixer) mixer_frame.grid(row=0, column=0, sticky='nwes') self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1)
def __init__(self, master, customers, payments, refresh): Toplevel.__init__(self,master) self.root = master self.refresh = refresh self.title("Check In") self.iconname = "Check In" self.name = StringVar() # variable for customer self.customers = customers # customers object self.payments = payments self.names = [] self.workout = StringVar() self.workouts = [] self.workouts_form = [] self.date = StringVar() self.date.set(strftime("%m/%d/%Y")) self.refresh_time = 15 # in minutes self.output = '' # for the output label at the bottom self.schedule = Schedule() self.logger = Logger() #throws IOError if file is open inf = Frame(self) inf.pack(padx=10,pady=10,side='top') Label(inf, text="Name:").grid(row=0,column=0,sticky=E,ipady=2,pady=2,padx=10) Label(inf, text='Date:').grid(row=1,column=0,sticky=E,ipady=2,pady=2,padx=10) Label(inf, text="Workout:").grid(row=2,column=0,sticky=E,ipady=2,pady=2,padx=10) self.name_cb = Combobox(inf, textvariable=self.name, width=30, values=self.names) self.name_cb.grid(row=0,column=1,sticky=W,columnspan=2) self.date_ent = Entry(inf, textvariable=self.date) self.date_ent.grid(row=1,column=1,sticky=W) self.date_ent.bind('<FocusOut>', self.update_workouts) Button(inf,text='Edit', command=self.enable_date_ent).grid(row=1,column=2,sticky=E) self.workout_cb = Combobox(inf, textvariable=self.workout, width=30, values=self.workouts_form,state='readonly') self.workout_cb.grid(row=2,column=1,sticky=W,columnspan=2) self.log_btn=Button(inf,text="Log Workout",command=self.log,width=12) self.log_btn.grid(row=3,column=1,columnspan=2,pady=4,sticky='ew') stf = Frame(self) stf.pack(padx=10,pady=10,fill='x',side='top') self.scrolled_text = ScrolledText(stf,height=15,width=50,wrap='word',state='disabled') self.scrolled_text.pack(expand=True,fill='both') self.update_workouts() self.update_names() self.bind('<Return>',self.log) self.name_cb.focus_set() # set the focus here when created #disable the date field self.disable_date_ent() #start time caller self.time_caller()
def __init__(self, parent): Toplevel.__init__(self, parent) self.resizable(width=False, height=False) self.wm_title("Setting") #1: Create a builder self.builder = builder = pygubu.Builder() #2: Load an ui file builder.add_from_file(PoResources.OPTION_DEF) #3: Set images path before creating any widget img_path = os.getcwd() + "/img" img_path = os.path.abspath(img_path) builder.add_resource_path(img_path) #4: Create the widget using a master as parent self.mainwindow = builder.get_object('option_frame', self) builder.import_variables(self) self.settings = Settings() self.load_config() # Connect method callbacks builder.connect_callbacks(self)
def __init__(self, parent, title, text, modal=True, _htest=False): """Show the given text in a scrollable window with a 'close' button If modal option set to False, user can interact with other windows, otherwise they will be unable to interact with other windows until the textview window is closed. _htest - bool; change box location when running htest. """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) # place dialog below parent if running htest self.geometry("=%dx%d+%d+%d" % (750, 500, parent.winfo_rootx() + 10, parent.winfo_rooty() + (10 if not _htest else 100))) #elguavas - config placeholders til config stuff completed self.bg = '#ffffff' self.fg = '#000000' self.CreateWidgets() self.title(title) self.protocol("WM_DELETE_WINDOW", self.Ok) self.parent = parent self.textView.focus_set() #key bindings for this dialog self.bind('<Return>',self.Ok) #dismiss dialog self.bind('<Escape>',self.Ok) #dismiss dialog self.textView.insert(0.0, text) self.textView.config(state=DISABLED) if modal: self.transient(parent) self.grab_set() self.wait_window()
def OnButtonClick(): e2.focus_set() e2.selection_range(0, END) e3.focus_set() e3.selection_range(0, END) e4.focus_set() e4.selection_range(0, END) win = Toplevel() win.title("Program Answer") if len(oracle_old_connection(e2.get(), e3.get())) > 0: cur = oracle_connection() alter_string = 'alter user %s identified by %s' % (e2.get(), e4.get()) cur.execute(alter_string) message = "Password Successfully Updated" msg = Message(win, text=message) msg.pack() button = Button(win, text='OK', command=win.destroy) button.pack() else: message = "Error!!!!" msg = Message(win, text=message) msg.pack() button = Button(win, text='OK', command=win.destroy) button.pack()
def __init__(self, wdgt, delay=1, follow=True): """ Initialize the ToolTip Arguments: wdgt: The widget this ToolTip is assigned to msg: A static string message assigned to the ToolTip msgFunc: A function that retrieves a string to use as the ToolTip text delay: The delay in seconds before the ToolTip appears(may be float) follow: If True, the ToolTip follows motion, otherwise hides """ self.wdgt = wdgt # The parent of the ToolTip is the parent of the ToolTips widget self.parent = self.wdgt.master # Initalise the Toplevel Toplevel.__init__(self, self.parent, bg='black', padx=1, pady=1) # Hide initially self.withdraw() # The ToolTip Toplevel should have no frame or title bar self.overrideredirect(True) # The msgVar will contain the text displayed by the ToolTip self.msgVar = StringVar() self.delay = delay self.follow = follow self.visible = 0 self.lastMotion = 0 Message(self, textvariable=self.msgVar, bg='#FFFFDD', aspect=1000).grid() # The test of the ToolTip is displayed in a Message widget
def destroy(self): registry.delete(self) Toplevel.destroy(self) # If this is Idle's last window then quit the mainloop # (Needed for clean exit on Windows 98) if not registry.dict: self.quit()
def __init__(self, app): self.app = app Toplevel.__init__(self, app) self.title("Reset Usage Counters") self.protocol("WM_DELETE_WINDOW", self.doCancel) f = Frame(self) f.pack() self.cbDL = {} for d in DLLIST: cbv = IntVar() t = "%s(%s)" % (DLNAMES[d], self.app.dataLoggers[d].getToNowStr()) cb = Checkbutton(f, text=t, variable=cbv) self.cbDL[d] = cbv cb.pack(anchor=W, padx=10) f = Frame(self) f.pack() self.bOK = Button(f, text="OK", width=12, command=self.doOK) self.bOK.pack(side=LEFT, padx=2, pady=5) self.bCancel = Button(f, text="Cancel", width=12, command=self.doCancel) self.bCancel.pack(side=LEFT, padx=2, pady=5)
def __init__(self, message, *args): self._prevent_execution_with_timeouts() Toplevel.__init__(self, self._get_parent()) self._init_dialog() self._create_body(message, args) self._create_buttons() self.wait_window(self)
def __init__(self, teamnum, teams, alliances, scores): Toplevel.__init__(self) self.title(string = "%s" % titlestring) self.teamnum = int(teamnum) self.teamnumber = teams[self.teamnum] self.score = scores[self.teamnum] self.elements = { # motoma! 'teamnumber':IntVar(), 'prescore':IntVar(), } self.elements['teamnumber'].set(self.teamnumber) self.elements['prescore'].set(self.score) # Starting our editing frame ef = LabelFrame(self, text = "Edit Team Information", relief=GROOVE, labelanchor="nw", width = 400, height = 150) ef.grid(row = 0, column = 0) ef.grid_propagate(0) Label(ef, text = "Team Number:").grid(row = 0, column = 1) Entry(ef, text = "%s" % self.teamnumber, textvar = self.elements['teamnumber']).grid(row = 0, column = 2) Label(ef, text = "Pre-Round Score:").grid(row = 1, column = 1) Entry(ef, text = "%s" % self.score, textvar = self.elements['prescore']).grid(row = 1, column = 2) Label(ef, text = "").grid(row = 2, column = 1) Button(ef, text = "Submit", command=self.submitchanges).grid(row = 3, column = 2)
def show_tooltip(self, x, y, text, background=TOOLTIP_BACKGROUND): """ Shows a tooltip containing the given |text| close to the point (|x|, |y|) on the canvas. """ x += self._canvas.winfo_rootx() + 10 y += self._canvas.winfo_rooty() + 10 geometry = '+%d+%d' % (x, y) if not self._tip: self._tip = Toplevel(self._canvas) self._tip.wm_overrideredirect(1) self._tip.wm_geometry(geometry) try: # for Mac OS self._tip.tk.call('::tk::unsupported::MacWindowStyle', 'style', self._tip._w, 'help', 'noActivates') except TclError: pass self.label = Label(self._tip, text=text, justify=LEFT, background=background, relief=SOLID, borderwidth=1, font=DEFAULT_FONT) self.label.pack() else: self._tip.geometry(geometry) self.label.config(text=text, background=background)
def __init__(self, master, app): Toplevel.__init__(self, master) self.config(background=factory.bg()) config = app.config id_ = config["global-osc-id"] host, port = config['host'], config['port'] client, cport = config['client'], config['client_port'] midi_receiver = app.midi_receiver.port_name() midi_transmitter = "n/a" # FIX ME main = VFrame(self) main.pack(anchor="nw", expand=True, fill=BOTH) image = Image.open("resources/logos/llia_logo_medium.png") photo = ImageTk.PhotoImage(image) lab_logo = Label(main, image=photo) main.add(lab_logo) south = factory.frame(main) main.add(south) acc = "Llia Version %s.%s.%s \n" % VERSION[0:3] acc += "(c) 2016 Steven Jones\n\n" acc += "OSC ID : %s\n" % id_ acc += "OSC Host : %-12s port : %s\n" % (host, port) acc += "OSC client : %-12s port : %s\n\n" % (client, cport) acc += "MIDI Receiver : %s\n" % midi_receiver acc += "MIDI Transmitter : %s\n" % midi_transmitter tx = factory.read_only_text(south, acc) tx.pack(pady=32) self.grab_set() self.mainloop()
def __init__(self, parent, filename, title): Toplevel.__init__(self, parent) self.wm_title(title) self.protocol("WM_DELETE_WINDOW", self.destroy) HelpFrame(self, filename).grid(column=0, row=0, sticky='nsew') self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1)
def key_cb(self, event=None): # call back function for keyboard events (except for Return) # handle numbers to set value key = event.keysym if key == 'Return': return #print 'Key:', key if len(self.typedValue) == 0 and self.topEntry is None: # create Tk label showing typed value x = event.x y = event.y #print 'create entry' self.topEntry = Toplevel() self.topEntry.overrideredirect(1) w = event.widget if event.x >= 0: self.topEntry.geometry('+%d+%d' % (w.winfo_rootx() + event.x + 10, w.winfo_rooty() + event.y)) else: self.topEntry.geometry('+%d+%d' % (w.winfo_rootx() + 10, w.winfo_rooty())) self.typedValueTK = Label(master=self.topEntry, text='', relief='sunken', bg='yellow') self.typedValueTK.pack() self.handleKeyStroke(event)
def openFlipWindow(self): """ open the flip window and initial all the button and text """ panel = Toplevel(self.root) panel.wm_title("Gesture Recognition") self.btn_flipl = tki.Button( panel, text="Flip Left", relief="raised", command=self.telloFlip_l) self.btn_flipl.pack(side="bottom", fill="both", expand="yes", padx=10, pady=5) self.btn_flipr = tki.Button( panel, text="Flip Right", relief="raised", command=self.telloFlip_r) self.btn_flipr.pack(side="bottom", fill="both", expand="yes", padx=10, pady=5) self.btn_flipf = tki.Button( panel, text="Flip Forward", relief="raised", command=self.telloFlip_f) self.btn_flipf.pack(side="bottom", fill="both", expand="yes", padx=10, pady=5) self.btn_flipb = tki.Button( panel, text="Flip Backward", relief="raised", command=self.telloFlip_b) self.btn_flipb.pack(side="bottom", fill="both", expand="yes", padx=10, pady=5)
def __init__(self, root, prtr, settings, log, *arg): Toplevel.__init__(self, root, *arg) self.protocol('WM_DELETE_WINDOW', self.delTop) self.title("Macro Buttons") self.app = root self.settings = settings self.printer = prtr self.log = log self.macroList = self.settings.getMacroList() fw = BUTTONWIDTH * 3 fh = BUTTONHEIGHT * 10 self.f = Frame(self, width = BUTTONWIDTH*3, height=BUTTONHEIGHT*10) for m in self.macroList: b = Button(self.f, text=m[MTEXT], width=BWIDTH, command=lambda macro=m[MNAME]: self.doMacro(macro)) x = (m[MCOL]-1) * BUTTONWIDTH y = (m[MROW]-1) * BUTTONHEIGHT b.place(relx=0.0, rely=0.0, y=y, x=x, anchor=NW) self.f.pack() geometry = "%dx%d+50+50" % (fw, fh) self.geometry(geometry)
def __init__(self, parent): Toplevel.__init__(self) img = ImageTk.PhotoImage(file=os.path.join(os.path.dirname(__file__), 'Icons/LMS8001_PLLSim.png')) self.tk.call('wm', 'iconphoto', self._w, img) self.parent = parent if (sys.platform == 'win32'): font_paths = matplotlib.font_manager.win32InstalledFonts( fontext='ttf') self.font_names = [] for font_path in font_paths: font_inst = matplotlib.ft2font.FT2Font(font_path) font_prop = matplotlib.font_manager.ttfFontProperty(font_inst) self.font_names.append(font_prop.name) elif (sys.platform == 'linux2'): font_list = matplotlib.font_manager.get_fontconfig_fonts() self.font_names = [ matplotlib.font_manager.FontProperties(fname=fname).get_name() for fname in font_list ] else: print 'Unsupported OS type. Exiting Preferences Window.' tkMessageBox.showinfo('Unsupported OS type', 'Exiting Preferences Window') self.destroy() self.initUI() center_Window(self) self.protocol("WM_DELETE_WINDOW", self.on_Quit)
def __init__(self, parent, title, menuItem='', filePath=''): """Get menu entry and url/ local file location for Additional Help User selects a name for the Help resource and provides a web url or a local file as its source. The user can enter a url or browse for the file. """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.resizable(height=False, width=False) self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Cancel) self.parent = parent self.result = None self.CreateWidgets() self.menu.set(menuItem) self.path.set(filePath) self.withdraw() #hide while setting geometry #needs to be done here so that the winfo_reqwidth is valid self.update_idletasks() #centre dialog over parent: self.geometry("+%d+%d" % ((parent.winfo_rootx() + ((parent.winfo_width()/2) -(self.winfo_reqwidth()/2)), parent.winfo_rooty() + ((parent.winfo_height()/2) -(self.winfo_reqheight()/2))))) self.deiconify() #geometry set, unhide self.bind('<Return>', self.Ok) self.wait_window()
def callback(event): event.widget.focus_set() print "clicked at", event.x, event.y if self.add_tasks_flg.get() == 1: # Select number of robots # Define elements of pop up window self.top = Toplevel() self.num_robots = StringVar(self.top) self.num_robots.set("1") # default value w = OptionMenu(self.top, self.num_robots, '1', '2', '3', '4').grid(row=0, column=1) text1 = Message(self.top, text="Number of robots:", width=150).grid(row=0, column=0) self.e = Entry(self.top, width=10) self.e.grid(row=1, column=1) text2 = Message(self.top, text="Task duration:", width=150).grid(row=1, column=0) text3 = Message(self.top, text="(s)", width=60).grid(row=1, column=2) newline = Message(self.top, text=" ").grid(row=2) button = Button(self.top, text='Enter', command=lambda: self.enter_task(event)).grid( row=3, column=1) button_cancel = Button(self.top, text='Cancel', command=self.cancel_task).grid(row=3, column=2) center(self.top)
def create_content(self): self.pop = Toplevel(self.master) self.pop.grab_set() # when you show the popup self.pop.wm_title(' ' * 20 + self._title_) self.pop.geometry('{:d}x{:d}+{:d}+{:d}'.format(*self._vertex_)) label0 = Label(self.pop, text=self._briefing_) label0.pack(side="top", fill="both", expand=True, padx=100, pady=20) # just a line bottom_hline_deco(self.pop) # lets create space to do some stuff ... row2fill = Frame(self.pop) for e in range(len(self._entries_)): self.ent_c.append( create_entry(row2fill, self._entries_[e], self._defvals_[e], self.entr_maxlen)) row2fill.pack(side="top", padx=1, pady=5) self.bottom_button_row() self.master.solv_b.config(bg='gray40', width=45) #cyan')
def __init__(self, parent, title, message, usedNames): """ message - string, informational message to display usedNames - list, list of names already in use for validity check """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.resizable(height=False, width=False) self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Cancel) self.parent = parent self.message = message self.usedNames = usedNames self.result = '' self.CreateWidgets() self.withdraw() #hide while setting geometry self.update_idletasks() self.geometry("+%d+%d" % ((parent.winfo_rootx() + ((parent.winfo_width() / 2) - (self.winfo_reqwidth() / 2)), parent.winfo_rooty() + ((parent.winfo_height() / 2) - (self.winfo_reqheight() / 2)) )) ) #centre dialog over parent self.deiconify() #geometry set, unhide self.wait_window()
class ConfusionMatrixViewer(): def __init__(self, class_number, matrix, kappa): self.class_number = class_number self.matrix = matrix self.kappa = kappa self.child_window = Toplevel(height = 800, width = 1500) self.child_window.title('Verification of image classification') def run(self): confusion_matrix_table = ConfusionMatrixTable(self.child_window, self.class_number, self.matrix) confusion_matrix_table.pack(padx = 5, pady = 5) kappa_label = Label(self.child_window, font = BOLD_FONT, text = 'Kappa Coefficient: {0}'.format(self.kappa)) kappa_label.pack(anchor = 'w', padx = 5) save_button = Button(self.child_window, text = 'Save Validation', relief = 'raised', width = 30, command = self._save_validation) save_button.pack(anchor = 'center', padx = 5, pady = 5) def _save_validation(self): save_validation_results(self.child_window, self.matrix, self.kappa)
def __init__(self, parent, title, text): """Show the given text in a scrollable window with a 'close' button """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.geometry( "=%dx%d+%d+%d" % (625, 500, parent.winfo_rootx() + 10, parent.winfo_rooty() + 10)) #elguavas - config placeholders til config stuff completed self.bg = '#ffffff' self.fg = '#000000' self.CreateWidgets() self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Ok) self.parent = parent self.textView.focus_set() #key bindings for this dialog self.bind('<Return>', self.Ok) #dismiss dialog self.bind('<Escape>', self.Ok) #dismiss dialog self.textView.insert(0.0, text) self.textView.config(state=DISABLED) self.wait_window()
def __init__(self, master, splash=True): Toplevel.__init__(self, master) self.title('MSTM - splash') ws = self.master.winfo_screenwidth() hs = self.master.winfo_screenheight() w = 400 h = 225 x = (ws / 2) - (w / 2) y = (hs / 2) - (h / 2) self.geometry('%dx%d+%d+%d' % (w, h, x, y)) try: self.splash_image = ImageTk.PhotoImage( Image.open(os.path.join('images', 'splash.png'))) except Exception as err: print('Can not load splash image\n%s' % err) self.label = ttk.Label(self, image=self.splash_image) self.label.place(x=0, y=0, width=w, height=h) self.entry = ttk.Entry(self) self.entry.insert(0, 'https://github.com/lavakyan/mstm-spectrum') self.entry.configure(state='readonly') self.entry.place(x=5, rely=0.9, width=w - 10) if splash: self.overrideredirect(True) # do magic # required to make window show before the program gets to the mainloop self.update() else: self.protocol('WM_DELETE_WINDOW', self.del_window) self.label.bind('<Button-1>', self.del_window) self.label.bind('<Button-2>', self.del_window)
def _io_binding(parent): # htest # root = Toplevel(parent) root.title("Test IOBinding") width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) root.geometry("+%d+%d"%(x, y + 150)) class MyEditWin: def __init__(self, text): self.text = text self.flist = None self.text.bind("<Control-o>", self.open) self.text.bind("<Control-s>", self.save) def get_saved(self): return 0 def set_saved(self, flag): pass def reset_undo(self): pass def open(self, event): self.text.event_generate("<<open-window-from-file>>") def save(self, event): self.text.event_generate("<<save-window>>") def update_recent_files_list(s, f): pass text = Text(root) text.pack() text.focus_set() editwin = MyEditWin(text) IOBinding(editwin)
def __init__(self, area, *args, **kwargs): Toplevel.__init__(self, area, *args, **kwargs) self.area = area self.wm_overrideredirect(1) self.wm_geometry("+10000+10000") self.bind('<Configure>', lambda event: self.update()) self.update()
def __init__(self, parent, title, message, used_names, _htest=False): """ message - string, informational message to display used_names - string collection, names already in use for validity check _htest - bool, change box location when running htest """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.resizable(height=FALSE, width=FALSE) self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Cancel) self.parent = parent self.message = message self.used_names = used_names self.create_widgets() self.withdraw() #hide while setting geometry self.update_idletasks() #needs to be done here so that the winfo_reqwidth is valid self.messageInfo.config(width=self.frameMain.winfo_reqwidth()) self.geometry("+%d+%d" % (parent.winfo_rootx() + (parent.winfo_width() / 2 - self.winfo_reqwidth() / 2), parent.winfo_rooty() + ((parent.winfo_height() / 2 - self.winfo_reqheight() / 2) if not _htest else 100)) ) #centre dialog over parent (or below htest box) self.deiconify() #geometry set, unhide self.wait_window()
def __init__(self, parent, title=None): Toplevel.__init__(self, parent) self.transient(parent) if title: self.title(title) self.parent = parent self.result = None body = Frame(self) self.initial_focus = self.body(body) body.pack(padx=5, pady=5) self.buttonbox() self.grab_set() if not self.initial_focus: self.initial_focus = self self.protocol("WM_DELETE_WINDOW", self.cancel) self.geometry("+%d+%d" % (parent.winfo_rootx()+50, parent.winfo_rooty()+50)) self.initial_focus.focus_set() self.wait_window(self)
def __init__(self, parent, title, message, used_names, _htest=False): """ message - string, informational message to display used_names - string collection, names already in use for validity check _htest - bool, change box location when running htest """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.resizable(height=FALSE, width=FALSE) self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Cancel) self.parent = parent self.message = message self.used_names = used_names self.create_widgets() self.withdraw() #hide while setting geometry self.update_idletasks() #needs to be done here so that the winfo_reqwidth is valid self.messageInfo.config(width=self.frameMain.winfo_reqwidth()) self.geometry( "+%d+%d" % ( parent.winfo_rootx() + (parent.winfo_width()/2 - self.winfo_reqwidth()/2), parent.winfo_rooty() + ((parent.winfo_height()/2 - self.winfo_reqheight()/2) if not _htest else 100) ) ) #centre dialog over parent (or below htest box) self.deiconify() #geometry set, unhide self.wait_window()
def documentation(version, w, h): def _setdoc(evt): w = evt.widget index = int(w.curselection()[0]) doc = w.get(index) textfield.config(state=NORMAL) textfield.delete('1.0', END) textfield.insert('1.0', docdic[doc]) textfield.config(state=DISABLED) r = Toplevel() w = int(w/2) h = int(h/2) r.geometry('{}x{}+{}+{}'.format(w, h, int(w/2), int(h/2))) r.wm_title('Documentation accpy version {}'.format(version)) lf = Frame(r) lf.pack(side=LEFT, fill=BOTH, expand=False) rf = Frame(r) rf.pack(side=RIGHT, fill=BOTH, expand=True) docmenuopts = ['General', 'Lattice editor', 'Citation'] docmenu = Listbox(lf) for entry in docmenuopts: docmenu.insert(END, entry) docmenu.pack(fill=BOTH, expand=True) docmenu.bind('<<ListboxSelect>>', _setdoc) scrollbar = Scrollbar(orient="vertical") textfield = Text(rf, xscrollcommand=scrollbar.set) textfield.pack(fill=BOTH, expand=True)
def show(self): self.root.withdraw() if self.flag: img_file = os.path.join(app.config.sk_share_dir, self.img + '.png') from sk1sdk.tkpng import load_icon load_icon(self.root, img_file, self.img) scrnWt = self.root.winfo_screenwidth() scrnHt = self.root.winfo_screenheight() winXPos = (scrnWt / 2) - (self.width / 2) winYPos = (scrnHt / 2) - (self.height / 2) self.win = Toplevel() self.win.overrideredirect(1) self.win.configure(background='black') self.banner = Label(self.win, image=self.img, cursor='watch', borderwidth=0) self.banner.pack() self.verlb = Label(self.win, text='version %s' % (config.version, ), bg='white') self.verlb.place(x=10, y=240) self.verlb['font'] += ' bold' self.txtlb = Label(self.win, text='Start...', bg='white') self.txtlb.place(x=10, y=265) self.progress_bar = SS_ProgressBar(self.win) self.progress_bar.pack(fill=X, side=TOP) geom = (self.width, self.height, winXPos, winYPos) self.win.geometry('%dx%d+%d+%d' % geom) self.win.update()
def __init__(self, master, apply_information, title='申请业务详情'): print 'apply_information', apply_information Toplevel.__init__(self) self.master = master self.apply_information = apply_information self.title(title) self.create_widget() self.pack_all()
def setup(self): if self.class_: self.root = Toplevel(self.master, class_=self.class_) else: self.root = Toplevel(self.master) self.root.title(self.title) self.root.iconname(self.title)