class GUI: """For reciprocal space maps""" def __init__(self, master): self.file_path = None self.RSM = None #Defaul scale for RSM and Linescan is logarithmic self.rsm_scale = StringVar() self.rsm_scale.set("log") self.line_scale = StringVar() self.line_scale.set("log") #Default parameters for RSM self.rsm_parallel_lower = -0.01 self.rsm_parallel_upper = 0 self.rsm_normal_lower = 0.5 self.rsm_normal_upper = 0.52 #Default parameters for linescan self.origin_parallel = -0.0007 self.origin_normal = 0.51192 self.linescan_angle = 0.0 self.linescan_width = 0.000015 self.window_frame = Frame(master, bd=2, relief=GROOVE) self.fileselect_button = Button(self.window_frame, text="Select XRDML file", command=self.select_file) self.busy_label = Label(self.window_frame, text="") self.savebutton1 = Button(self.window_frame, text="Save RSM", command=lambda: self.savefigure(self.rsm_plot_figure)) self.savebutton2 = Button(self.window_frame, text="Save Linescan", command=lambda: self.savefigure(self.linescan_plot_figure)) self.rsm_frame = Frame(self.window_frame, bd=2, relief=GROOVE) self.rsm_label = Label(self.rsm_frame, text="Amerigo - RSM Viewer Space Map") self.rsm_parallel_lower_label = Label(self.rsm_frame, text="Lower q-parallel bound") self.rsm_parallel_lower_entry = Entry(self.rsm_frame) self.rsm_parallel_upper_label = Label(self.rsm_frame, text="Upper q-parallel bound") self.rsm_parallel_upper_entry = Entry(self.rsm_frame) self.rsm_normal_lower_label = Label(self.rsm_frame, text="Lower q-normal bound") self.rsm_normal_lower_entry = Entry(self.rsm_frame) self.rsm_normal_upper_label = Label(self.rsm_frame, text="Upper q-normal bound") self.rsm_normal_upper_entry = Entry(self.rsm_frame) self.rsm_sclae_linear = Radiobutton(self.rsm_frame, text="Linear", variable=self.rsm_scale, value="linear") self.rsm_sclae_log = Radiobutton(self.rsm_frame, text="Logarithmic", variable=self.rsm_scale, value="log") self.create_rsm_button = Button(self.rsm_frame, text="Create RSM", command=self.create_rsm) self.linescan_frame = Frame(self.window_frame, bd=2, relief=GROOVE) self.linescan_label = Label(self.linescan_frame, text="Line Scan") self.origin_parallel_label = Label(self.linescan_frame, text="Point of origin parallel coordinate") self.origin_normal_label = Label(self.linescan_frame, text="Point of origin normal coordinate") self.linescan_angle_label = Label(self.linescan_frame, text="Angle to parallel axis in degrees") self.linescan_width_label = Label(self.linescan_frame, text="Linescan thickness intervall") self.origin_parallel_entry = Entry(self.linescan_frame) self.origin_normal_entry = Entry(self.linescan_frame) self.linescan_angle_entry = Entry(self.linescan_frame) self.linescan_width_entry = Entry(self.linescan_frame) self.create_linescan_button = Button(self.linescan_frame, text="Create linescan", command=self.create_line_scan) self.line_scale_log = Radiobutton(self.linescan_frame, text="Logarithmic", variable=self.line_scale, value="log") self.line_scale_linear = Radiobutton(self.linescan_frame, text="Linear", variable=self.line_scale, value="linear") self.rsm_plot_frame = Frame(master, relief=GROOVE, bd=2) self.rsm_plot_figure = Figure() self.rsm_canvas = FigureCanvasTkAgg(self.rsm_plot_figure, master=self.rsm_plot_frame) self.rsm_toolbar = NavigationToolbar2TkAgg(self.rsm_canvas, self.rsm_plot_frame) self.rsm_toolbar.update() self.rsm_canvas.show() self.linescan_plot_frame = Frame(master, relief=GROOVE, bd=2) self.linescan_plot_figure = Figure() self.linescan_canvas = FigureCanvasTkAgg(self.linescan_plot_figure, master=self.linescan_plot_frame) self.linescan_toolbar = NavigationToolbar2TkAgg(self.linescan_canvas, self.linescan_plot_frame) self.linescan_toolbar.update() self.linescan_canvas.show() self.place_widgets() def place_widgets(self): self.window_frame.place(x=10, y=10, width=425, height=520) self.fileselect_button.place(x=5, y=5, width=415, height=25) self.savebutton1.place(x=5, y=485, height=25, width=205) self.savebutton2.place(x=215, y=485, height=25, width=200) self.rsm_frame.place(x=5, y=35, height=220, width=415) self.rsm_label.place(x=5, y=5, height=25, width=405) self.rsm_parallel_lower_label.place(x=5, y=35, height=25, width=200) self.rsm_normal_lower_label.place(x=5, y=65, height=25, width=200) self.rsm_parallel_upper_label.place(x=5, y=95, height=25, width=200) self.rsm_normal_upper_label.place(x=5, y=125, height=25, width=200) self.rsm_parallel_lower_entry.place(x=210, y=35, height=25, width=200) self.rsm_parallel_upper_entry.place(x=210, y=65, height=25, width=200) self.rsm_normal_lower_entry.place(x=210, y=95, height=25, width=200) self.rsm_normal_upper_entry.place(x=210, y=125, height=25, width=200) self.rsm_sclae_linear.place(x=5, y=155, height=25, width=200) self.rsm_sclae_log.place(x=210, y=155, height=25, width=200) self.create_rsm_button.place(x=5, y=185, height=25, width=405) self.linescan_frame.place(x=5, y=260, width=415, height=220) self.linescan_label.place(x=5, y=5, width=405, height=25) self.origin_parallel_label.place(x=5, y=35, width=200, height=25) self.origin_normal_label.place(x=5, y=65, width=200, height=25) self.linescan_angle_label.place(x=5, y=95, width=200, height=25) self.linescan_width_label.place(x=5, y=125, width=200, height=25) self.origin_parallel_entry.place(x=210, y=35, width=200, height=25) self.origin_normal_entry.place(x=210, y=65, width=200, height=25) self.linescan_angle_entry.place(x=210, y=95, width=200, height=25) self.linescan_width_entry.place(x=210, y=125, width=200, height=25) self.line_scale_linear.place(x=5, y=155, width=200, height=25) self.line_scale_log.place(x=210, y=155, width=200, height=25) self.create_linescan_button.place(x=5, y=185, width=405, height=25) self.rsm_plot_frame.place(x=440, y=10, width=480, height=520) self.rsm_canvas.get_tk_widget().place(x=5, y=5, height=470, width=470) self.linescan_plot_frame.place(x=925, y=10, width=480, height=520) self.linescan_canvas.get_tk_widget().place(x=5, y=5, height=470, width=470) def select_file(self): self.file_path = askopenfilename() self.busy_label.configure(text="Be patient, I have a lot of data to read") self.RSM = Reciprocal(self.file_path) self.RSM.readfile() self.RSM.refine_data() self.busy_label.configure(text="") def create_rsm(self): if self.RSM is not None: self.busy_label.configure(text="Busy! Plotting %s data points." % len(self.RSM.intensity)) if self.rsm_parallel_lower_entry.get() != "": self.rsm_parallel_lower = float(self.rsm_parallel_lower_entry.get()) if self.rsm_parallel_upper_entry.get() != "": self.rsm_parallel_upper = float(self.rsm_parallel_upper_entry.get()) if self.rsm_normal_lower_entry.get() != "": self.rsm_normal_lower = float(self.rsm_normal_lower_entry.get()) if self.rsm_normal_upper_entry.get() != "": self.rsm_normal_upper = float(self.rsm_normal_upper_entry.get()) x = self.RSM.q_parallel y = self.RSM.q_normal if self.rsm_scale == "linear": z = self.RSM.intensity else: z = self.RSM.log_intensity ax = self.rsm_plot_figure.gca() ax.clear() ax.tricontourf(x, y, z, 1000, cmap="gist_rainbow") ax.tricontour(x, y, z, 8, colors="black") ax.set_ylabel(r"$q_{\perp} [\AA^{-1}]$") ax.set_xlabel(r"$q_{\parallel} [\AA^{-1}]$") ax.set_xlim(self.rsm_parallel_lower, self.rsm_parallel_upper) ax.set_ylim(self.rsm_normal_lower, self.rsm_normal_upper) ax.axis("equal") self.rsm_plot_figure.subplots_adjust(left=0.2) self.rsm_canvas.draw() self.busy_label.configure(text="") else: self.busy_label.configure(text="Select XRDML file first!") def create_line_scan(self): if self.RSM is not None: self.busy_label.configure(text="Busy! Processing %s data points." % len(self.RSM.intensity)) if self.origin_parallel_entry.get() != "": self.origin_parallel = float(self.origin_parallel_entry.get()) if self.origin_normal_entry.get() != "": self.origin_normal = float(self.origin_normal_entry.get()) if self.linescan_angle_entry.get() != "": self.linescan_angle = float(self.linescan_angle_entry.get()) if self.linescan_width_entry.get() != "": self.linescan_width = float(self.linescan_width_entry.get()) line = self.RSM.create_line_scan(self.origin_parallel, self.origin_normal, self.linescan_angle, self.linescan_width) bx = self.linescan_plot_figure.gca() bx.clear() bx.plot(line[0], line[1], '-o') bx.set_xlim(-0.005, 0.005) bx.set_yscale(self.line_scale.get()) bx.set_ylabel("Counts") bx.set_xlabel(r"Distance from origin $[\AA]^{-1}$") self.linescan_canvas.draw() self.busy_label.configure(text="") else: self.busy_label.configure(text="Select XRDML file first!") def savefigure(self, figure): if figure: figure.savefig(self.file_path+"_picture.png")
class TextureCanvas(): def __init__(self, root): self.root = root self.window = root.window self.texture_frame = Frame(self.window) self.texture_frame.place(relx=0.5, rely=0.5, anchor=CENTER) self.canvas = Canvas(self.texture_frame, width=500, height=500) self.canvas.pack() self.texture = Image.new('RGB', size=(0, 0)) self.tk_image = ImageTk.PhotoImage(self.texture) self.img_area = self.canvas.create_image(250, 250, image=self.tk_image) def gen_image(self): """Generate an image using the TextureGenerator class and a settings Dictionary :param settings: Settings dictionary which is used as input for the Generator :type settings: dict """ setup_obj = self.root.setup.parse_setup() generated_texture = TextureGenerator(setup_obj).gen() self.texture = generated_texture.resize((400, 400), Image.NEAREST) self.tk_image = ImageTk.PhotoImage(self.texture) self.canvas.itemconfig(self.img_area, image=self.tk_image) def export_image(self): filename = asksaveasfilename(title='Export Image', filetypes=(('PNG Image', '*.png'), ), defaultextension='') self.texture.save(filename)
def make_label(x, y, text,): f = Frame(canvas, height=CELL_SIZE, width=CELL_SIZE) f.pack_propagate(0) f.place(x=x, y=y) label = Label(f, font=("Helvetica", 14), text=text) label.pack(fill=tkinter.BOTH, expand=1) return label
def printSignIn(canvas): canvas.config(height=210, width=300) frame = Frame() frame.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.8) labelTitle = Label(frame, text="LOGIN") labelTitle.grid(row=0, column=1, pady=10) labelUsername = Label(frame, text="Username") labelUsername.grid(row=1, column=0, pady=5) entryUsername = Entry(frame) entryUsername.grid(row=1, column=1, columnspan=2) labelPassword = Label(frame, text="Password") labelPassword.grid(row=2, column=0, pady=5) entryPassword = Entry(frame, show="*") entryPassword.grid(row=2, column=1, columnspan=2) labelMensaje = Label(frame, text="") labelMensaje.grid(row=3, column=0, columnspan=2, pady=2) buttonsignIn = Button(frame, text="SignIn", command=lambda: signIn( entryUsername.get(), entryPassword.get(), labelMensaje, canvas )) buttonsignIn.grid(row=4, column=1, pady=10)
def init(): root = Tk() root.title("Proyecto tbd") canvas = Canvas(root, height=150, width=200) canvas.pack() frame = Frame() frame.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.8) buttonsignIn = Button(frame, text="INGRESAR", command=lambda: printSignIn(canvas)) buttonsignIn.grid(row=0, column=0, pady=10, padx=20) buttonsignIn = Button(frame, text="REGISTRARSE", command=lambda: printSignUp(canvas)) buttonsignIn.grid(row=1, column=0, pady=10, padx=20) def on_closing(): if messagebox.askokcancel(title="Quit", message="Do you want to quit?"): signOff() root.destroy() root.protocol("WM_DELETE_WINDOW", on_closing) root.mainloop()
def create_upper_menu(self): # Uper section frame = Frame(self.master, bg='#a0dbd1', bd=4) frame.place(relx=0.5, rely=0.1, relwidth=0.75, relheight=0.1, anchor='n') # Set curve and figure variable and trace changes self.figure_val = StringVar(frame) self.create_OptionMenu(self.figure_val, frame, option_figure[0], 0.05, option_figure) self.curve_val = IntVar(frame) self.create_OptionMenu(self.curve_val, frame, option_curve[0], 0.30, option_curve) # Set color button color = TkinterCustomButton(master=frame, height=52, text="Color", command=self.color_option) color.place(relx=0.55) # Set clear button clear = TkinterCustomButton( master=frame, height=52, text="Clear", command=lambda: self.lower_frame.delete("all")) clear.place(relx=0.80)
def SearchWindow(): w = Frame(root, width=400, height=240, bg='#57deff') w.place(x=0, y=28) # entrybox def on_enter(e): s.delete(0, 'end') def on_leave(e): if s.get() == '': s.insert(0, 'Please enter song name...') def searchbar(): search = s.get() return search def filetypebar(): ch = optionsbox.get() return ch optionsbox = ttk.Combobox(w, width=10, value=options) optionsbox.current(0) optionsbox.place(x=150, y=92) s = Entry(w, width=30, fg="grey") s.bind("<FocusIn>", on_enter) s.bind("<FocusOut>", on_leave) s.insert(0, 'Please enter song name...') s.place(x=100, y=42) Button(w, width=20, height=0, text="Download", command=lambda: AudioDownloader(searchbar()), border=0, bg='#ffffff', fg='#000000').place(x=120, y=142)
def main(): menubar = Menu(root) filemenu = Menu(menubar, tearoff=0) filemenu.add_command(label="Login", command=ShowLoginForm) filemenu.add_command(label="Exit", command=Exit) menubar.add_cascade(label="Account", menu=filemenu) root.config(menu=menubar) root.protocol('WM_DELETE_WINDOW', Exit) # intercept [X] to stop mainloop() Title = Frame(root, bd=1, relief=SOLID) Title.pack(pady=10) Title.place(relx=0.5, rely=0.45, anchor='center') lbl_display = Label(Title, text="Inventory System", font=('arial', 45)) lbl_display.pack() lbl_display2 = Label(Title, text="Please Login to Continue ( Account > Login )", font=('arial', 14), fg='red') lbl_display2.pack() ShowLoginForm() root.lower() root.mainloop()
def puzzle_window(Num, valueRB, thisBoard=None): global frame4, root2 if thisBoard is None: root2 = Tk() frame4 = Frame(master=root2) root2.title("Custom N-Queen Puzzle by Ezz") root2.geometry("300x300") frame4.place(x=10, y=10) global frame5 frame5 = Frame(master=root2) N = Num tiles = [] numOfNodes = N * N initial = board(tiles, numOfNodes, N) initial.tiles.append(tile(0, -1, -1, "blue")) createBasicBoard(root2, initial, valueRB) # A basic board is made else: initial = thisBoard changeButton(root2, initial, valueRB) isGoal(initial) if initial.goal is False: IDAstar(initial) resetQueen(initial) calQueenConflicts(initial) printConflicts(initial)
def __init__(self, *rect): """\ Parameters ---------- rect (list[int, int, int, int], optional): [default=None] if provided, must be [left, top, right, bottom] of current window """ topWin = GetForeWin() x, y, w, h = rect if len(rect) == 4 else GetWindowRect(topWin) root = Tk() root.overrideredirect(True) root.title("-*Filter*-") root.config(bg='red') root.attributes('-transparentcolor', 'black', '-topmost', True, '-alpha', 0.5) root.geometry('{}x{}+{}+{}'.format(w, h, x, y)) f = Frame(root, bg='black') f.place(anchor='center', relx=0.5, rely=0.5, width=-6, relwidth=1, height=-6, relheight=1) root.update_idletasks() SetWindowLong(GetForeWin(), -8, topWin) root.mainloop()
def Faculty_Student_homePage(): global head_Frame1, head_Frame2, head_Label, btn1, btn2, Canvas1 head_Frame1.destroy() head_Frame2.destroy() head_Label.destroy() Canvas1.destroy() btn1.destroy() btn2.destroy() Canvas1 = Canvas(window) Canvas1.config(bg="#ffa710", width=New_Image_Size_Width, height=New_Image_Size_Height) Canvas1.pack(expand=True, fill='both') head_Frame1 = Frame(window, bg="#333945", bd=5) head_Frame1.place(relx=0.25, rely=0.1, relwidth=0.5, relheight=0.13) head_Frame2 = Frame(head_Frame1, bg="#EAF0F1") head_Frame2.place(relx=0.01, rely=0.05, relwidth=0.98, relheight=0.9) btn2 = Button(window, text="Login", bg='black', fg='black', command=Login) btn2.place(relx=0.53, rely=0.3, relwidth=0.2, relheight=0.1)
def setLogoFrame(): logoFrame = Frame(width="245", height="70", bg="#880e0e") logoFrame.place(x=0, y=1) img_logo = PhotoImage(file="umlogo.png") lblLogo = Label(logoFrame, image=img_logo, bd=0) lblLogo.place(x=43, y=5)
def __init__(self, master, colour): try: os.mkdir("Employee") os.mkdir("Department") except FileExistsError: print("Directory already exists") else: pass self.__logged = Toplevel(master) First.__init__(self, self.__logged, colour) self.frame1 = LabelFrame(self.__logged) self.frame1.pack() self.employee_name = StringVar() self.mail = StringVar() self.employee_code = StringVar() self.department_code = StringVar() self.department_name = StringVar() self.employee_surname = StringVar() frame = Frame(self.__logged, padx=15, pady=15) frame.place(x=400, y=200) Button(frame, text="Employee Details", font=("Calibri", 13), width=20, pady=15, command=lambda: (self.frame1.destroy(), frame.pack(side="left"), System.detail_employee(self))).pack() Button(frame, text="Add Employee", font=("Calibri", 13), width=20, pady=15, command=lambda: (self.frame1.destroy(), frame.pack(side="left"), System.add_employee(self))).pack() Button(frame, text="Department Details", font=("Calibri", 13), width=20, pady=15, command=lambda: ( self.frame1.destroy(), frame.pack(side="left"), System.detail_department(self))).pack() Button(frame, text="Add Department", font=("Calibri", 13), width=20, pady=15, command=lambda: (self.frame1.destroy(), frame.pack(side="left"), System.add_department(self))).pack() Button(self.__logged, text="Back", width=15, pady=10, command=lambda: (main.deiconify(), self.__logged.destroy())).pack()
class update_class : def __init__(self): self.root = Tk() self.root.wm_maxsize(1000, 1000) self.root.wm_minsize(1000, 1000) self.frame1 = Frame(self.root, bg='gray') self.frame1.place(x=0, height=1000, y=0, width=1000) self.frame1.config() self.Welcome_label = Label(self.frame1, text="ADD", font=('Comic Sans MS', 70), bg='gray', fg='white') self.Welcome_label.pack() self.Choice_label = Label(self.frame1, text="Enter batch name - ", font=('Comic Sans MS', 45), bg='gray', fg='white') self.Choice_label.pack(padx=0, pady=80, anchor='n') self.batch_name = StringVar() ##Global self.batch_entry = Entry(self.frame1, bd=16, textvar=self.batch_name) self.batch_entry.pack(anchor='n') self.cont_button = Button(self.frame1, text='Continue', width=16, font=("Comic Sans MS", 16),command = self. add_student) self.cont_button.pack(pady=20) def add_student(self): global Batch_name Batch_name = self.batch_name.get() self.root.destroy() update_stu()
def __init__(self, root, x, y, name, config, remote_control): super().__init__(root, x, y, name) remote = remote_control frame = Frame(root, bg=remote["color"], width=remote["width"], height=remote["height"]) frame.place(x=x, y=y) self._config = config self._key_codes = [] self._pressed_key_codes = [] for i in range(0, len(remote["key_rows"])): row = remote["key_rows"][i] for j in range(0, len(row["buttons"])): button_setup = row["buttons"][j] if button_setup != None: code = button_setup.get("code", "KEY_" + button_setup["name"]) self._key_codes.append(code) command = partial(self._key_press, code) button = Button(frame, text=button_setup["name"], width=remote["key_width"], height=remote["key_height"], command=command, justify=CENTER, highlightbackground=remote["color"]) button.grid(row=i, column=j, padx=8, pady=8) frame.configure(width=remote["width"], height=remote["height"])
class firstPage: frame1: Frame def __init__(self): self.root = Tk() self.root.wm_maxsize(1000, 1000) self.root.wm_minsize(1000, 1000) self.frame1 = Frame(self.root, bg='gray') self.frame1.place(x=0, height=1000, y=0, width=1000) self.frame1.config() self.Welcome_label = Label(self.frame1, text="WELCOME", font=('Comic Sans MS', 70), bg='gray', fg='white') self.Welcome_label.pack() self.Choice_label = Label(self.frame1, text="Choose a option - ", font=('Comic Sans MS', 45), bg='gray', fg='white') self.Choice_label.pack(padx=0, pady=80, anchor='n') self.add_button = Button(self.frame1, text='Add a class', width=16, font=("Comic Sans MS", 16), command=self.add) self.add_button.pack(pady=20) self.update_button = Button(self.frame1, text='Add a student', width=16, font=("Comic Sans MS", 16), command=self.update) self.update_button.pack(pady=20) self.att_button = Button(self.frame1, text='Attendance', width=16, font=("Comic Sans MS", 16), command=self.att_b) self.att_button.pack(pady=20) self.gen_button = Button(self.frame1, text='Generate CSV', width=16, font=("Comic Sans MS", 16), command=self.csv_button) self.gen_button.pack(pady=20) self.exit_button = Button(self.frame1, text='Exit', width=16, font=("Comic Sans MS", 16),command=self.exit_b) self.exit_button.pack(pady=20) self.root.mainloop() def att_b(self): self.root.destroy() attendance() def csv_button(self): global count count = 1 self.root.destroy() csv_b() def add(self): self.root.destroy() add_class() def update(self): self.root.destroy() update_class() def exit_b(self): self.root.destroy()
def complete_history_command(self): """Displays the complete tournament history ... in a text-frame""" read = SimpleOverview() comp_his = read.read_local pok_his = comp_his['poker'] df = DataFrame(pok_his) cols = df.columns.tolist() i = 1 while i <= 6: # making date the first column by moving all columns to the right, 6 times. (apparantly that works) cols = cols[-1:] + cols[:-1] i += 1 df = df[cols] text_frame_complete_history = Frame(self.master, bg=default_C) text_frame_complete_history.place(relx=0, rely=0.1, relwidth=1, relheight=0.9) text_complete_history = Text(text_frame_complete_history, bg='#070707', bd=5, exportselection=0, fg='#196619', height=HEIGHT, width=WIDTH) text_complete_history.insert(INSERT, str(df)) text_complete_history.config(state=DISABLED) text_complete_history.pack()
def remove_command_value(self): """Removes the actual tournament with the index chosen""" text_frame_remove = Frame(self.master, bg=default_C) text_frame_remove.place(relx=0.25, rely=0.5, relwidth=0.43, relheight=0.048) text_remove = Text(text_frame_remove, bg='#070707', bd=5, exportselection=0, fg='#196619', height=self.HEIGHT, width=self.WIDTH) text_remove.insert(INSERT, 'Removing data from JSON ...') text_remove.config(state=DISABLED) text_remove.pack() try: text_remove.update() choice_remove = self.remove_index.get() add_remove = AddRemove() add_remove.del_from_json(choice_remove) except: self.error() sleep(0.5) text_remove.destroy()
def create_components(self, args=None): """Create UI components of the book list dialog :param args: unused here """ self.create_bg(color="#12a4d9") self.create_header(title="View Books") label_frame = Frame(self, bg='black') label_frame.place(relx=0.1, rely=0.3, relwidth=0.8, relheight=0.5) y = 0.25 Label(label_frame, text="%-10s%-40s%-30s%-20s" % ('BID', 'Title', 'Author', 'Status'), bg='black', fg='white').place(relx=0.07, rely=0.1) Label( label_frame, text="-------------------------------------------------------------" "---------------", bg='black', fg='white').place(relx=0.05, rely=0.2) for i in Book().read(): Label(label_frame, text="%-10s%-30s%-30s%-20s" % (i[0], i[1], i[2], i[3]), bg='black', fg='white').place(relx=0.07, rely=y) y += 0.1 quit_btn = Button(self, text="Quit", bg='#f7f1e3', fg='black', command=self.destroy) quit_btn.place(relx=0.4, rely=0.9, relwidth=0.18, relheight=0.08)
def exit_command(self): """Updates online JSON, deletes local JSON - exits thereafter""" text_frame_exit_command = Frame(self.master, bg=default_C) text_frame_exit_command.place(relx=0, rely=0.1, relwidth=1, relheight=0.9) text_exit_command = Text(text_frame_exit_command, bg='#070707', bd=5, exportselection=0, fg='#196619', height=HEIGHT, width=WIDTH) text_exit_command.insert( INSERT, 'Updating JSON ... Exiting thereafter ... Thanks for now ...') text_exit_command.config(state=DISABLED) text_exit_command.pack() text_exit_command.update() update = JsonBin() update.update_bin() update.remove_local_json() sleep(1.5) self.master.destroy()
class Example(Frame): def __init__(self): super().__init__() self.initUI() def initUI(self): self.master.title("Color chooser") self.pack(fill=BOTH, expand=1) self.btn = Button(self, text="Choose Color", command=self.onChoose) self.btn.place(x=30, y=30) self.frame = Frame(self, border=1, relief=SUNKEN, width=100, height=100) self.frame.place(x=160, y=30) def onChoose(self): (rgb, hx) = colorchooser.askcolor() self.frame.config(bg=hx)
def loader(): global loadfilename if loadfilename != None: logger.info(messages.LOADFILE_CLEAR.format(loadfilename)) loadfilename = None # topframe which provides the student file upload utility topframe = Frame(window, bg="#80c1ff") topframe.place(rely=0.06, relx=0.015, relwidth=0.97, relheight=0.22) searchButton = Button(topframe, text="Choose Data File", font=("Roboto", 14, "bold"), fg="Brown", bg="#54EE4A", bd=5, relief="raised", command=lambda: chooseFile(filedisplay)) searchButton.place(relx=0.25, rely=0.32, relwidth=0.50, relheight=0.30) middleframe = LabelFrame(window, bg="#acdcdc", text="File Path", font=("Roboto", 13, "bold")) middleframe.place(rely=0.30, relx=0.015, relwidth=0.97, relheight=0.16) filedisplay = Label(middleframe, bg="#acdcdc", text="No Chosen File", font=("Comic Sans MS", 14)) filedisplay.pack() bottomframe = Frame(window, bg="#BC04BF") bottomframe.place(rely=0.48, relx=0.015, relwidth=0.97, relheight=0.51) loadDataButton = Button(bottomframe, text="Upload data to DB", font=("Roboto", 14, "bold"), fg="Brown", bg="#54EE4A", bd=5, relief="raised", command=lambda: loadData(filedisplay)) loadDataButton.place(rely=0.25, relx=0.25, relheight=0.15, relwidth=0.50) backButton = Button(bottomframe, text="Back to Homepage", font=("Roboto", 14, "bold"), fg="Brown", bg="#54EE4A", bd=5, relief="raised", command=lambda: callHomescreen(allframes)) backButton.place(rely=0.50, relx=0.25, relheight=0.15, relwidth=0.50) allframes = [] allframes.append(middleframe) allframes.append(topframe) allframes.append(bottomframe)
def askFor(): entryFrame = Frame(root, bg=_from_rgb((104, 155, 202)), width=int(screenWidth / 4.5), height=int(screenHeight / 5)) entryFrame.place(x=int(screenWidth / 2.5), rely=.6) entryText = tk.Label( entryFrame, bg=_from_rgb((104, 155, 202)), text="Swipe One Card then click Submit, or type 'Exit'") entryText.place(relx=.5, rely=.4, anchor=CENTER) def get(): global pw pw = entry.get() entry.delete(0, 'end') entry = tk.Entry(entryFrame) entry.focus_set() entry.place(relx=.5, rely=.6, anchor=CENTER) entry.bind("<Return>", get()) entryButton = tk.Button(entryFrame, text="Submit", command=get()) entryButton.place(relx=.5, rely=.8, anchor=CENTER) entryButton.bind("<Return>", get())
def createUI(self): FONT_SETTINGS = ('Consolas', 12) root = Tk() _ICON=PhotoImage(height=32, width=32) _ICON.blank() root.title('rsachatclient') root.resizable(width=True, height=True) root.geometry('1000x700') root.tk.call('wm', 'iconphoto', root._w, _ICON) frame = Frame(root, bg='#000') frame.place(relx=0, rely=0, relwidth=1, relheight=1) txt = Entry(frame, bg='#000', fg='#fff', font=FONT_SETTINGS) txt.place(relx=0.1, rely=0.95, relwidth=1, relheight=0.05) aliasLabel = Label(frame, bg='#000', fg='#fff', font=FONT_SETTINGS) aliasLabel.place(relx=0, rely=0.95, relwidth=0.1, relheight=0.05) outputMsgBox = Text(frame, bg='#000', fg='#fff', font=FONT_SETTINGS) outputMsgBox.place(relx=0, rely=0, width=1000, relheight=0.95) txt.bind('<Key>', self.input_control) txt.focus() self.UIRoot = root aliasLabel.configure(text=self.alias) self.inputTextBox = txt self.outputMsgBox = outputMsgBox
def getFrame(self, y0, y1, x0, x1): frame = Frame(self.root, height=(y1 - y0) * self.size - self.size / 100, width=(x1 - x0) * self.size - self.size / 100) frame.pack_propagate(0) frame.place(x=x0 * self.size, y=y0 * self.size) return frame
def Faculty_Menu(): global head_Frame1, head_Frame2, head_Label, Submit_Button, Canvas1, labelFrame, backBtn head_Frame1.destroy() head_Frame2.destroy() head_Label.destroy() Canvas1.destroy() Submit_Button.destroy() Canvas1 = Canvas(window) Canvas1.config(bg="#ffa710", width=New_Image_Size_Width, height=New_Image_Size_Height) Canvas1.pack(expand=True, fill='both') head_Frame1 = Frame(window, bg="#333945", bd=5) head_Frame1.place(relx=0.25, rely=0.1, relwidth=0.5, relheight=0.13) head_Frame2 = Frame(head_Frame1, bg="#EAF0F1") head_Frame2.place(relx=0.01, rely=0.05, relwidth=0.98, relheight=0.9) head_Label = Label(head_Frame2, text="Faculty MENU", fg='black') head_Label.place(relx=0.25, rely=0.15, relwidth=0.5, relheight=0.5) btn1 = Button(window, text="Update Student Details", bg='black', fg='black', command=UpdateStudentInfo) btn1.place(relx=0.28, rely=0.3, relwidth=0.45, relheight=0.1) btn2 = Button(window, text="Delete Student", bg='black', fg='black', command=deleteStudent) btn2.place(relx=0.28, rely=0.4, relwidth=0.45, relheight=0.1) btn3 = Button(window, text="View All Students", bg='black', fg='black', command=Display_All_Student_Info) btn3.place(relx=0.28, rely=0.5, relwidth=0.45, relheight=0.1) btn4 = Button(window, text="Search Student", bg='black', fg='black', command=SearchStudent) btn4.place(relx=0.28, rely=0.6, relwidth=0.45, relheight=0.1) backBtn = Button(window, text="< BACK", bg='#455A64', fg='black', command=Faculty) backBtn.place(relx=0.5, rely=0.9, relwidth=0.18, relheight=0.08)
def create_window(): t = Tk() make_labels(t) t.geometry('1000x600') t.config(bg="#090b10") frame_insert = Frame(t, height="15", width="80", bd=2, bg="cyan", highlightbackground="#090b10") insert_new = Entry(frame_insert, width="80", font=("arial", 13), bg="#090b10", fg="#2df0a0", bd="4", relief="flat", insertbackground="cyan") insert_new.grid(column=2) frame_insert.place(x=40, y=520) submit = Button(t, text="A D D", width="10", height="1", font=("Helvetica", 8, "bold"), fg="#090b10", bg="#2df0a0", activebackground="#1a1a1a", activeforeground="#8fdcdf", pady="2", command=lambda: get_link(insert_new.get(), t)) submit.config(highlightbackground="#8fdcdf", highlightcolor="#2df0a0", highlightthickness=10, relief="solid") submit.place(x=810, y=515) submit2 = Button(t, text="refresh", width="10", height="1", font=("Helvetica", 8, "bold"), fg="#090b10", bg="#2df0a0", activebackground="#1a1a1a", activeforeground="#8fdcdf", pady="2", command=lambda: make_labels(t)) submit2.config(highlightbackground="#8fdcdf", highlightcolor="#2df0a0", highlightthickness=10, relief="solid") submit2.place(x=810, y=450) prompt() t.mainloop()
def create_content_frame(self): """Creates the frame embedding the content of the dialog :return: an initialized and positioned frame """ frame = Frame(self, bg='black') frame.place(relx=0.1, rely=0.4, relwidth=0.8, relheight=0.4) return frame
class attendance: def __init__(self): self.root = Tk() self.root.wm_maxsize(1000, 1000) self.root.wm_minsize(1000, 1000) self.frame1 = Frame(self.root, bg='gray') self.frame1.place(x=0, height=1000, y=0, width=1000) self.frame1.config() self.Welcome_label = Label(self.frame1, text="Attendance", font=('Comic Sans MS', 70), bg='gray', fg='white') self.Welcome_label.pack() self.Choice_label = Label(self.frame1, text="Enter batch name - ", font=('Comic Sans MS', 45), bg='gray', fg='white') self.Choice_label.pack(padx=0, pady=80, anchor='n') self.batch_name = StringVar() ##Global self.batch_entry = Entry(self.frame1, bd=16, textvar=self.batch_name) self.batch_entry.pack(anchor='n') ################## self.topic_label = Label(self.frame1, text="Enter topic name - ", font=('Comic Sans MS', 45), bg='gray', fg='white') self.topic_label.pack(padx=0, pady=80, anchor='n') self.topic_name = StringVar() ##Global self.topic_entry = Entry(self.frame1, bd=16, textvar=self.topic_name) self.topic_entry.pack(anchor='n') self.cont_button = Button(self.frame1, text='Continue', width=16, font=("Comic Sans MS", 16),command = self. att_student) self.cont_button.pack(pady=20) def att_student(self): global count global Batch_name global topic_name count = 1 Batch_name = self.batch_name.get() topic_name = self.topic_name.get() + str("".join((str(date.today()).split('-')))) conn = sqlite3.connect("main_database.db") c = conn.cursor() #print('alter table ' + Batch_name + ' add column ' + topic_name + ' text ') c.execute('alter table '+Batch_name+' add column '+topic_name+' text ') conn.commit() self.root.destroy() act()
def showCatgory(): Cat1_window = tk.Toplevel(root) Cat1_window.geometry('300x400') Cat1_window.resizable(0, 0) Cat1_window.title('1000萬發票 消費品項統計表') frame1 = Frame(Cat1_window) frame1.place(x=0, y=10, width=280, height=400) scrBar1 = tk.Scrollbar(Cat1_window) scrBar1.pack(side=tk.RIGHT, fill=tk.Y) tree1 = Treeview(Cat1_window, columns=('c1', 'c2'), show='headings', yscrollcommand=scrBar1.set) tree1.column('c1', width=200, anchor='center') tree1.column('c2', width=80, anchor='center') tree1.heading('c1', text='品項') tree1.heading('c2', text='出現次數') tree1.pack(side=tk.LEFT, fill=tk.Y) scrBar1.config(command=tree1.yview) tree1.bind('<Button-1>', treeviewClick) sort1000 = [[v[1], v[0]] for v in Cat_1000.items()] sort1000.sort() sort1000.reverse() for z in sort1000: tree1.insert('', 'end', text=z[1], values=(z[1], z[0])) Cat2_window = tk.Toplevel(root) Cat2_window.geometry('300x400') Cat2_window.resizable(0, 0) Cat2_window.title('200萬發票 消費品項統計表') frame2 = Frame(Cat2_window) frame2.place(x=0, y=10, width=280, height=400) scrBar2 = tk.Scrollbar(Cat2_window) scrBar2.pack(side=tk.RIGHT, fill=tk.Y) tree2 = Treeview(Cat2_window, columns=('w1', 'w2'), show='headings', yscrollcommand=scrBar2.set) tree2.column('w1', width=200, anchor='center') tree2.column('w2', width=80, anchor='center') tree2.heading('w1', text='品項') tree2.heading('w2', text='出現次數') tree2.pack(side=tk.LEFT, fill=tk.Y) scrBar2.config(command=tree2.yview) tree2.bind('<Button-1>', treeviewClick) sort200 = [[v[1], v[0]] for v in Cat_200.items()] sort200.sort() sort200.reverse() for z in sort200: tree2.insert('', 'end', text=z[1], values=(z[1], z[0]))
def _make_buttons(self): '''Create action buttons at the bottom.''' button_row = self.my_grid.size + self.Y_PADDING + (self.BUTTON_PANEL_HEIGHT - 2 * self.BUTTON_PADDING) button_frame = Frame(self) button_frame.place(x=self.my_grid.size - self.X_PADDING, y=button_row) self.play_game_button = Button(button_frame, text="Play") self.play_game_button.pack(side=LEFT, padx=self.BUTTON_PADDING, pady=self.BUTTON_PADDING)
class LoginGui(object): def __init__(self, root): self.welcome_text = 'Prihlaseny' if User.is_loaded_session() else "" self.response_text = StringVar(root, value=self.welcome_text) self.top_frame = Frame(root, width=400, height=400) self.middle_frame = Frame(root, width=300, height=300) self.top_frame.pack(fill="both", expand=True, padx=20, pady=20) self.middle_frame.place(in_=self.top_frame, anchor='c', relx=.5, rely=.5) self.l_email = Label(self.middle_frame, text="Email") self.e_email = Entry(self.middle_frame) self.l_pass = Label(self.middle_frame, text="Password") self.e_pass = Entry(self.middle_frame, show="*") self.l_sign_up = Label(self.middle_frame, text="Sign up", fg='blue', cursor='hand2') self.l_req_result = Label(self.middle_frame, textvariable=self.response_text) self.b_submit = Button(self.middle_frame, text="Login") self.l_email.grid(row=0, sticky=E) self.e_email.grid(row=0, column=1) self.l_pass.grid(row=1, column=0, sticky=E) self.e_pass.grid(row=1, column=1) self.b_submit.grid(row=2, column=1, sticky=E) self.l_sign_up.grid(row=3, column=1, sticky=E) self.l_req_result.grid(row=4) self.l_sign_up.bind('<Button-1>', self.sing_up_callback) self.b_submit.bind('<Button-1>', self.login) self.root = root self.root.mainloop() def login(self, event): response = User.login(self.e_email.get(), self.e_pass.get()) self.response_text.set(response) if User.is_loaded_session(): self.root.destroy() @staticmethod def sing_up_callback(event): webbrowser.open_new(Config.SIGN_UP_URL) @staticmethod def show_login(): root = tkinter.Tk(className="Productivity optimizer") LoginGui(root) root.mainloop()
def additems(i, doreturn=False, bgcolor="#555"): returnable = [] for item in i: global totalitems totalitems += 1 ff = Frame(f, bg=bgcolor) item.body = item.author.name + ' || ' + item.fullname + '\n' + item.body item.body = str(totalitems) + '\n' + item.body ibody = item.body.replace('\n\n', '\n') ifinal = '' for paragraph in ibody.split('\n'): ifinal += '\n'.join(textwrap.wrap(paragraph)) ifinal += '\n' item.body = ifinal ww = 680 wh = 10 wx = 20 wy = 20 #print(ww, wh, wx, wy) ff.ww = ww ff.wh = wh ff.wx = wx ff.wy = wy ff.body = item.body ff.sourceitem = item ff.configure(width=ww, height=wh) ff.place(x=wx, y=wy) ff.bind("<B1-Motion>", framedrag) ff.bind("<ButtonRelease-1>", resetdrag) ff.pack_propagate(0) l = Label(ff, text=item.body, bg="#777") l.place(x=10,y=10) rt = Text(ff, width= 15, height= (len(ifinal.split('\n'))) - 2) rt.sourceitem = item rt.place(x=400,y=10) rb = Button(ff, text="Reply", command= lambda rep=rt: reply(rep)) rb.place(x=400,y=wh-20) ff.rt = rt ff.rb = rb if not doreturn: widgets.append(ff) else: returnable.append(ff) if doreturn: return returnable else: refreshscreen()
class Gui: def __init__(self, master): self.arduino = None self.port = "COM7" self.updater = Thread() self.windowframe = Frame(master) self.port_entry = Entry(self.windowframe) self.port_label = Label(self.windowframe, text="COM Port:") self.arduino_connect_button = Button(self.windowframe, text="Connect Arduino", command=self.connect_arduino) self.start_button = Button(self.windowframe, text="Start", command=self.start) self.stop_Button = Button(self.windowframe, text="Exit", command=master.destroy) self.temperature_plot = Plot(self.windowframe, "Time [min]", "T\n\n°C", 500) self.place_widgets() def place_widgets(self): self.windowframe.place(x=10, y=10, width=500, height=560) self.port_label.place(x=0, y=0, height=25, width=160) self.port_entry.place(x=170, y=0, height=25, width=160) self.arduino_connect_button.place(x=340, y=0, width=160, height=25) self.start_button.place(x=0, y=30, width=245, height=25) self.stop_Button.place(x=255, y=30, height=25, width=245) self.temperature_plot.place(x=0, y=60, height=500, width=500) def connect_arduino(self): if self.port_entry.get() != "": self.port = self.port_entry.get() self.arduino = Arduino(self.port) sleep(1) def start(self): def update(): start_time = datetime.now() while True: thermocouple_temperature = self.arduino.thermocouple_temperature.get() runtime = (datetime.now() - start_time).seconds / 60.0 self.temperature_plot.add_datapoint(runtime, thermocouple_temperature) self.updater._target = update self.updater.start() self.arduino.start_updater()
class GUI: """A simple GUI for the PLD heater""" def __init__(self, master): self.PLD_port = "COM5" self.PLD_address = 5 self.PLD = None self.pyrometer_port = "COM10" self.pyrometer = None self.active_plot = 1 self.start_time = None self.label_updater = Thread() self.pyrometer_pld_communication = Thread() self.icon_left = PhotoImage(file="Button_left.png") self.icon_right = PhotoImage(file="Button_right.png") self.window_frame = Frame(master, bd=2, relief=GROOVE) self.sensor_frame = Frame(self.window_frame, bd=2, relief=GROOVE) self.parameter_frame = Frame(self.window_frame, bd=2, relief=GROOVE) self.graph_frame = Frame(self.window_frame, bd=2, relief=GROOVE) self.connect_frame = Frame(self.window_frame, bd=2, relief=GROOVE) self.log_frame = Frame(self.window_frame, bd=2, relief=GROOVE) self.plot_frame = Frame(self.window_frame, bd=2, relief=GROOVE) self.oven_temperature_label = Label(self.sensor_frame, text="Oven temperature: °C") self.external_temperature_label = Label(self.sensor_frame, text="Sample temperature: °C") self.working_setpoint_label = Label(self.sensor_frame, text="Working setpoint: °C") self.working_output_label = Label(self.sensor_frame, text="Working ouput %") self.power_output_label = Label(self.parameter_frame, text="Power output %") self.power_output_entry = Entry(self.parameter_frame) self.power_output_setter_button = Button(self.parameter_frame, text="Set power output [%]", command=self.set_target_output_power, state=DISABLED) self.setpoint_label = Label(self.parameter_frame, text="Setpoint: °C") self.setpoint_entry = Entry(self.parameter_frame) self.setpoint_setter_button = Button(self.parameter_frame, text="Set target setpoint [°C]", command=self.set_target_setpoint, state=DISABLED) self.mode_label = Label(self.parameter_frame, text="Manual control mode") self.mode_switcher_button = Button(self.parameter_frame, text="Switch mode", command=self.switch_mode, state=DISABLED) self.external_sensor_mode_label = Label(self.parameter_frame, text="External sensor mode off") self.external_sensor_mode_button = Button(self.parameter_frame, text="Enable external sensor mode", command=self.enable_external_sensor_temperature, state=DISABLED) self.hold_temperature_button = Button(self.parameter_frame, text="Hold temperature", command=self.hold_temperature, state=DISABLED) self.PLD_com_port_entry = Entry(self.connect_frame) self.PLD_com_port_label = Label(self.connect_frame, text="PLD COM Port") self.PLD_slave_address_entry = Entry(self.connect_frame) self.PLD_salve_address_label = Label(self.connect_frame, text="PLD slave Address (Default 1)") self.PLD_connect_button = Button(self.connect_frame, text="Connect PLD", command=self.connect_pld) self.pyrometer_com_port_entry = Entry(self.connect_frame) self.pyrometer_com_port_label = Label(self.connect_frame, text="Pyrometer COM Port") self.pyrometer_connect_button = Button(self.connect_frame, text="Connect Pyrometer", command=self.connect_pyrometer) self.start_label_updater_button = Button(self.connect_frame, text="Start", command=self.start_label_updater, state=DISABLED) self.log_label = Label(self.log_frame, text="Temperature Log") self.log_text = Text(self.log_frame) self.switch_plot_left_button = Button(self.plot_frame, command=self.switch_plot_left, image=self.icon_left) self.switch_plot_right_button = Button(self.plot_frame, command=self.switch_plot_right, image=self.icon_right) self.plot_label = Label(self.plot_frame, text="Oven temperature") self.pyrometer_plot_frame = Frame(self.plot_frame) self.oven_temperature_plot_frame = Frame(self.plot_frame) self.power_ouput_plot_frame = Frame(self.plot_frame) self.pyrometer_plot = Plot(self.pyrometer_plot_frame, "Time [min]", "T\n\n°C", 350) self.power_ouput_plot = Plot(self.power_ouput_plot_frame, "Time [min]", "P\n\n%", 350) self.oven_temperature_plot = Plot(self.oven_temperature_plot_frame, "Time [min]", "T\n\n°C", 350) self.place_widgets() def place_widgets(self): """Place each widgets""" self.window_frame.place(x=10, y=10, height=415, width=1010) self.connect_frame.place(height=105, width=630, x=10, y=10) self.pyrometer_com_port_label.place(height=25, width=200, x=10, y=10) self.pyrometer_com_port_entry.place(height=25, width=200, x=215, y=10) self.pyrometer_connect_button.place(height=25, width=200, x=420, y=10) self.PLD_com_port_label.place(height=25, width=200, x=10, y=40) self.PLD_com_port_entry.place(height=25, width=200, x=215, y=40) self.PLD_connect_button.place(height=25, width=200, x=420, y=40) self.PLD_salve_address_label.place(height=25, width=200, x=10, y=70) self.PLD_slave_address_entry.place(height=25, width=200, x=215, y=70) self.start_label_updater_button.place(height=25, width=200, x=420, y=70) self.parameter_frame.place(height=135, width=630, x=10, y=125) self.setpoint_label.place(height=25, width=200, x=10, y=10) self.setpoint_entry.place(height=25, width=200, x=215, y=10) self.setpoint_setter_button.place(height=25, width=200, x=420, y=10) self.power_output_label.place(height=25, width=200, x=10, y=40) self.power_output_entry.place(height=25, width=200, x=215, y=40) self.power_output_setter_button.place(height=25, width=200, x=420, y=40) self.mode_switcher_button.place(height=25, width=405, x=215, y=70) self.mode_label.place(height=25, width=200, x=10, y=70) self.external_sensor_mode_label.place(height=25, width=200, x=10, y=100) self.external_sensor_mode_button.place(height=25, width=200, x=215, y=100) self.hold_temperature_button.place(height=25, width=200, x=420, y=100) self.sensor_frame.place(height=135, width=220, x=10, y=270) self.oven_temperature_label.place(height=25, width=200, x=10, y=10) self.external_temperature_label.place(height=25, width=200, x=10, y=40) self.working_setpoint_label.place(height=25, width=200, x=10, y=70) self.working_output_label.place(height=25, width=200, x=10, y=100) self.log_frame.place(height=135, width=400, x=240, y=270) self.log_text.place(height=115, width=380, x=10, y=10) self.plot_frame.place(x=640, y=10, width=360, height=395) self.switch_plot_left_button.place(x=5, y=5, height=30, width=30) self.switch_plot_right_button.place(x=325, y=5, height=30, width=30) self.plot_label.place(x=35, y=5, height=25, width=295) self.pyrometer_plot_frame.place(x=5, y=40, width=350, height=350) self.oven_temperature_plot_frame.place(x=5, y=40, width=350, height=350) self.power_ouput_plot_frame.place(x=5, y=40, width=350, height=350) self.pyrometer_plot.place(x=0, y=0, width=350, height=350) self.oven_temperature_plot.place(x=0, y=00, width=350, height=350) self.power_ouput_plot.place(x=0, y=0, width=350, height=350) self.oven_temperature_plot_frame.lift() def start_label_updater(self): """Read values from instrument objects every second, display them, plot them and write in a logfile""" self.start_time = datetime.now() def update_labels(): while True: pyrometer_temperature = "---" oven_temperature = "---" working_output = "---" working_setpoint = "---" runtime = (datetime.now() - self.start_time).seconds / 60.0 if self.PLD is not None: oven_temperature = self.PLD.oven_temp.get() self.oven_temperature_plot.add_datapoint(runtime, oven_temperature) self.oven_temperature_label.configure(text="Oven temperature: %s °C" % oven_temperature) working_output = self.PLD.working_output.get() self.power_ouput_plot.add_datapoint(runtime, working_output) self.working_output_label.configure(text="Working output: %s %%" % working_output) working_setpoint = self.PLD.working_setpoint.get() self.working_setpoint_label.configure(text="Working setpoint: %s °C" % working_setpoint) if self.pyrometer is not None: pyrometer_temperature = self.pyrometer.temperature.get() self.pyrometer_plot.add_datapoint(runtime, pyrometer_temperature) self.external_temperature_label.configure(text="Sample temperature %s °C" % pyrometer_temperature) logstring = "Time: " + strftime("%X") \ + ("Oven temperature: %s °C" % oven_temperature).ljust(28, " ") \ + ("Power Output %s %%" % working_output).ljust(28, " ")\ + ("Working Setpoint: %s °C" % working_setpoint).ljust(28, " ")\ + ("Pyrometer temperature: %s °C" % pyrometer_temperature).ljust(28, " ") \ + "\n" printstring = "Time: " + strftime("%X") \ + ("Oven temperature: %s °C" % oven_temperature).ljust(28, " ") \ + ("Pyrometer temperature: %s °C" % pyrometer_temperature).ljust(28, " ")\ + "\n" self.log_text.insert(END, printstring) sleep(0.5) self.label_updater._target = update_labels self.label_updater.start() if self.PLD is not None and self.pyrometer is not None: self.start_pyrometer_pld_communication() if self.PLD is not None: self.mode_switcher_button.configure(state=NORMAL) self.power_output_setter_button.configure(state=NORMAL) self.PLD.switch_to_manual_mode() self.mode_label.configure(text="Manual operation mode") self.power_output_setter_button.configure(state=NORMAL) def connect_pld(self): """Connect to the PLD Eurotherm controller, start in manual mode""" if self.PLD_com_port_entry.get() != "": self.PLD_port = self.PLD_com_port_entry.get() if self.PLD_slave_address_entry.get() != "": self.PLD_address = int(self.PLD_slave_address_entry.get()) self.PLD = PLD(self.PLD_port, self.PLD_address) try: self.PLD.switch_to_manual_mode() except IOError: sleep(0.5) self.PLD.switch_to_manual_mode() self.PLD.start_oven_temperature_listener() self.PLD.start_working_output_listener() self.PLD.start_working_setpoint_listener() self.PLD.start_serial_io_handler() self.start_label_updater_button.configure(state=NORMAL) def connect_pyrometer(self): """Connect to the pyrometer""" if self.pyrometer_com_port_entry.get() != "": self.pyrometer_port = self.pyrometer_com_port_entry.get() self.pyrometer = Pyrometer(self.pyrometer_port) self.pyrometer.start_temperature_listener() self.start_label_updater_button.configure(state=NORMAL) self.external_sensor_mode_button.configure(state=NORMAL) def start_pyrometer_pld_communication(self): """Start supplying the PLD with the pyrometer temperature as external sensor temperature""" def talk(): while True: self.PLD.external_sensor_temperature.put(self.pyrometer.temperature) sleep(1) self.pyrometer_pld_communication._target = talk self.pyrometer_pld_communication.start() def set_target_setpoint(self): """Write the target setpoint in the entry widget to the instrument""" self.PLD.target_setpoint = float(self.setpoint_entry.get()) self.setpoint_label.configure(text="Setpoint %s °C" % self.PLD.target_setpoint) self.PLD.write_target_setpoint(self.PLD.target_setpoint) def set_target_output_power(self): """Write the target ouput power in the entry to the instrument""" self.PLD.power_output = float(self.power_output_entry.get()) self.power_output_label.configure(text="Power ouput %s%%" % self.PLD.power_output) self.PLD.write_manual_output_power(self.PLD.power_output) def switch_mode(self): """Switch the instrument between manual and automatic mode""" if not self.PLD.operation_mode: self.PLD.switch_to_manual_mode() self.PLD.operation_mode = 1 self.mode_label.configure(text="Manual operation mode") self.power_output_setter_button.configure(state=NORMAL) self.setpoint_setter_button.configure(state=DISABLED) elif self.PLD.operation_mode: self.PLD.switch_to_automatic_mode() self.PLD.operation_mode = 0 self.mode_label.configure(text="Automatic operation mode") self.setpoint_setter_button.configure(state=NORMAL) self.power_output_setter_button.configure(state=DISABLED) def enable_external_sensor_temperature(self): """Enabele using an external temperarture sensor for the PLD""" self.PLD.set_external_sensor_temperature_mode() self.hold_temperature_button.configure(state=NORMAL) def hold_temperature(self): """Switch the PLD to manual mode and hold the current power output""" self.setpoint_setter_button.configure(state=DISABLED) self.power_output_setter_button.configure(state=NORMAL) self.PLD.hold_current_temperature() def switch_plot_left(self): """Switch the displayed plot""" if self.active_plot: self.active_plot -= 1 self.show_plot() def switch_plot_right(self): """Switch the displayed plot""" if self.active_plot < 2: self.active_plot += 1 self.show_plot() def show_plot(self): """Switch the displayed plot""" if self.active_plot == 0: self.pyrometer_plot_frame.lift() self.plot_label.configure(text="Pyrometer temperature") if self.active_plot == 1: self.oven_temperature_plot_frame.lift() self.plot_label.configure(text="Oven temperature") if self.active_plot == 2: self.power_ouput_plot_frame.lift() self.plot_label.configure(text="Power Output")
def initUI(self): #top frame using all the remaining space innerTopFrame = Frame(self, background="black") innerTopFrame.pack(fill=BOTH, expand=1) #CLOSE Label innerBottomLeftFrame = Frame(self, background="black") innerBottomLeftFrame.place(x=0, width=self.wRoot/2, y=self.hRoot-200, height=200) closeLabel = Label(innerBottomLeftFrame, bg="black", fg="black", text="CLOSE", font=("Comic Sans MS", 48, "bold")) innerBottomLeftFrame.bind("<Enter>", lambda f: closeLabel.config(fg="white")) innerBottomLeftFrame.bind("<Leave>", lambda f: closeLabel.config(fg="black")) innerBottomLeftFrame.bind("<Button-1>", lambda f: self.root.quit()) closeLabel.bind("<Button-1>", lambda f: self.root.quit()) closeLabel.pack(fill=BOTH) #SHUT DOWN Label innerBottomRightFrame = Frame(self, background="black") innerBottomRightFrame.place(x=self.wRoot/2, width=self.wRoot/2, y=self.hRoot-200, height=200) shutdownLabel = Label(innerBottomRightFrame, bg="black", fg="black", text="SHUT DOWN", font=("Comic Sans MS", 48, "bold")) innerBottomRightFrame.bind("<Enter>", lambda f: shutdownLabel.config(fg="white")) innerBottomRightFrame.bind("<Leave>", lambda f: shutdownLabel.config(fg="black")) innerBottomRightFrame.bind("<Button-1>", self.shutdown) shutdownLabel.bind("<Button-1>", self.shutdown) shutdownLabel.pack(fill=BOTH) #design the FullScreenApp self.pack(fill=BOTH, expand=1)