def pick(self): """ Select points. .. note:: Before selection points, a plot should have been created from which points may be selected. Returns ------- Points : List of tuples A list of two-element tuples, holding the x and y coordinates of the selected points. """ self.root.wm_title(self.windowTitle) try: self.canvas.show() except AttributeError: # Seems to be dispensable with newer (> about 3) matplotlib versions pass tk.mainloop() # Prepare return value self.points = [] for p in self.pointList: self.points.append((p.xdata, p.ydata)) return self.points[:]
def doGUI(self, hostname=None): self.master = Tk() self.master.title('Blessclient - MFA') textmsg = 'Enter your AWS MFA code: ' if hostname: textmsg = 'Enter your AWS MFA code to connect to {}: '.format( hostname) Label(self.master, text=textmsg).grid(row=0) self.e1 = Entry(self.master) self.e1.grid(row=0, column=1, padx=4) Button(self.master, text='OK', command=self.show_entry_fields, default=ACTIVE).grid(row=3, column=0, sticky=W, pady=4) Button(self.master, text='Cancel', command=self.quit).grid(row=3, column=1, sticky=W, pady=4) self.center() self.master.bind('<Return>', self.show_entry_fields) self.master.lift() self.master.attributes('-topmost', True) self.master.focus_force() self.e1.focus_set() if platform.system() == 'Darwin': # Hack to get the GUI dialog focused in OSX # https://stackoverflow.com/questions/1892339/how-to-make-a-tkinter-window-jump-to-the-front/37235492#37235492 tmpl = 'tell application "System Events" to set frontmost of every process whose unix id is {} to true' script = tmpl.format(os.getpid()) subprocess.check_call(['/usr/bin/osascript', '-e', script]) mainloop()
def doGUI(self, hostname=None): self.master = Tk() self.master.title('Blessclient - MFA') textmsg = 'Enter your AWS MFA code: ' if hostname: textmsg = 'Enter your AWS MFA code to connect to {}: '.format( hostname) Label(self.master, text=textmsg).grid(row=0) self.e1 = Entry(self.master) self.e1.grid(row=0, column=1, padx=4) Button(self.master, text='OK', command=self.show_entry_fields, default=ACTIVE).grid(row=3, column=0, sticky=W, pady=4) Button(self.master, text='Cancel', command=self.quit).grid(row=3, column=1, sticky=W, pady=4) self.center() self.master.bind('<Return>', self.show_entry_fields) self.master.lift() self.master.attributes('-topmost', True) self.master.focus_force() self.e1.focus_set() if platform.system() == 'Darwin': # Hack to get the GUI dialog focused in OSX os.system( '/usr/bin/osascript -e \'tell app "Finder" to set frontmost of process "python" to true\'' ) mainloop()
def show(self): """ Show the GUI. """ try: self.canvas.show() except AttributeError: self.canvas.draw() tk.mainloop()
def findContinuum(self): """ Interactively find the continuum estimate. Returns ------- State : dictionary The following keys are defined: - points: A list of two-float tuples holding the x,y location of the selected points. - continuum : Array holding the continuum estimate at the given x-values. - splineKind : A string specifying the selected spline option. - normalizedData : An array holding the normalized data. """ self.root.wm_title(self.windowTitle) self.canvas.show() tk.mainloop() return self._getState()
def pick(self): """ Select points. .. note:: Before selection points, a plot should have been created from which points may be selected. Returns ------- Points : List of tuples A list of two-element tuples, holding the x and y coordinates of the selected points. """ self.root.wm_title(self.windowTitle) self.canvas.show() tk.mainloop() # Prepare return value self.points = [] for p in self.pointList: self.points.append((p.xdata, p.ydata)) return self.points[:]
def interactiveFit(self): """ Carry out the interactive fit Returns ------- Parameters : dict Dictionary mapping parameter name to the value. Active parameters : dict Dictionary mapping active parameter names (not including any numbers) to value Active component : int Number of the 'active component'. Counting starts at one. """ self.root.wm_title(self.windowTitle) self.canvas.show() tk.mainloop() # Prepare return value aps = {"off": self._model["off"]} n = str(self._activeComponent) for p in self._compPars: aps[p] = self._model[p + n] return self._model.parameters(), aps, self._activeComponent
def interactiveFit(self): """ Carry out the interactive fit Returns ------- Parameters : dict Dictionary mapping parameter name to the value. Active parameters : dict Dictionary mapping active parameter names (not including any numbers) to value Active component : int Number of the 'active component'. Counting starts at one. """ self.root.wm_title(self.windowTitle) self.canvas.show() tk.mainloop() # Prepare return value aps = {"off":self._model["off"]} n = str(self._activeComponent) for p in self._compPars: aps[p] = self._model[p+n] return self._model.parameters(), aps, self._activeComponent
def show(self): """ Show the GUI. """ self.canvas.show() tk.mainloop()
canvas = FigureCanvasTkAgg(fig, master=root) # A tk.DrawingArea. canvas.draw() canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1) toolbar = NavigationToolbar2TkAgg(canvas, root) toolbar.update() canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1) def on_key_press(event): print("you pressed {}".format(event.key)) key_press_handler(event, canvas, toolbar) canvas.mpl_connect("key_press_event", on_key_press) def _quit(): root.quit() # stops mainloop root.destroy() # this is necessary on Windows to prevent # Fatal Python Error: PyEval_RestoreThread: NULL tstate button = Tk.Button(master=root, text="Quit", command=_quit) button.pack(side=Tk.BOTTOM) Tk.mainloop() # If you put root.destroy() here, it will cause an error if the window is # closed with the window manager.
def mainloop(self): Tk.mainloop()
def mainloop(): Tk.mainloop()
filemenu = tk.Menu(menubar, tearoff=0) filemenu.add_command(label='Open...', command=self.file_open) filemenu.add_separator() filemenu.add_command(label='Exit', command=root.quit) menubar.add_cascade(label='File', menu=filemenu) helpmenu = tk.Menu(menubar, tearoff=0) helpmenu.add_command(label='About', command=self.show_about) menubar.add_cascade(label='Help', menu=helpmenu) self.master.config(menu=menubar) def show_about(self): """ Display an About dialogue box. """ toplevel = tk.Toplevel(self.master, bg='white') toplevel.transient(self.master) toplevel.title('About') tk.Label(toplevel, text='A simple iris viewer', fg='navy', bg='white').pack(pady=20) tk.Label(toplevel, text="Based on Scitools' Iris", bg='white').pack() tk.Button(toplevel, text='Close', command=toplevel.withdraw).pack(pady=30) if __name__ == '__main__': root = tk.Tk() irisview_window = IrisView(root) root.title('irisview') tk.mainloop()
def run(self): Tk.mainloop()