def makeView(self, master): frame = mtk.Frame(master, **self.configArgs) bg = frame.cget('bg') bg = convertToColorCode(master, bg) l = mtk.Label(frame, text=self.label, width=self.labelWidth, anchor="w", bg=bg) self.variable = mtk.StringVar(frame) self.variable.set(self.defaultEntry) self.optionMenu = mtk.OptionMenu(frame, self.variable, command=self.valueChanged, *self.options) self.optionMenu.config( bg=bg, highlightthickness=0, activebackground=colorscale( bg, 0.95)) #, activeforeground=colorscale(bg,1.5) ) if (self.boxWidth): self.optionMenu.config(width=self.boxWidth) if (self.direction == "vertical"): l.pack(side=mtk.TOP, fill=mtk.X) self.optionMenu.pack(side=mtk.BOTTOM, fill=mtk.X, expand=True) else: l.pack(side=mtk.LEFT, fill=mtk.X) self.optionMenu.pack(side=mtk.RIGHT, fill=mtk.X, expand=True) frame.pack(fill=mtk.X, expand=True) return frame
def __init__(self, parent, **kwargs): tk.Frame.__init__(self, parent, **kwargs) self.scan_number_Var = tk.StringVar() self.photo = tk.PhotoImage(master=self, file="misc/folder.gif") # Creating the GUI elements self.path_file_entries_LF = ttk.LabelFrame( self, text="Path and File Name", ) self.folder_Label = ttk.Label( self.path_file_entries_LF, text="Folder:", ) self.folder_path_Entry = ttk.Entry( self.path_file_entries_LF, width=30, state="disabled", ) self.folder_path_choose_Button = tk.Button( self.path_file_entries_LF, height=15, width=20, state="disabled", command=self.get_folder_path, image=self.photo, ) self.file_name_Label = ttk.Label(self.path_file_entries_LF, text="File name:") self.file_name_Entry = ttk.Entry( self.path_file_entries_LF, width=30, state="disabled", ) self.scan_number_Label = ttk.Label(self.path_file_entries_LF, textvariable=self.scan_number_Var) # Sticking to the grid self.path_file_entries_LF.grid(column=0, row=0, columnspan=3, rowspan=2, padx=5, pady=5) self.folder_Label.grid(column=0, row=0) self.folder_path_Entry.grid( column=1, row=0, padx=5, pady=5, ) self.folder_path_choose_Button.grid( column=2, row=0, padx=5, ) self.file_name_Label.grid(column=0, row=1) self.file_name_Entry.grid(column=1, row=1, padx=5, pady=5) self.scan_number_Label.grid(column=2, row=1, padx=5, pady=5)
def replace_user_with_guess(self, event): self.user_entry["state"] = "disabled" self.guess = tk.StringVar() self.guess.set("Who's This Pokemon?") self.guess_box = tk.Entry(self, textvariable=self.guess) self.guess_box.pack(side="bottom") self.guess_box.bind("<Key-Return>", self.update_score) self.guess_box.bind("<Key-Return>", self.show_guess_with_answer, "+") self.guess_box.bind("<Key-Return>", self.create_next_button, "+")
def makeView(self, master): frame = mtk.Frame(master, **self.configArgs) bg = frame.cget('bg') l = mtk.Label(frame, width=15, text=self.label, bg=bg, anchor="w") v = mtk.StringVar(frame, value=self.defaultEntry) self.ent = mtk.Entry(frame, textvariable=v) self.ent.bind("<Return>", self.enter) l.pack(side=mtk.LEFT, padx=5) self.ent.pack(side=mtk.LEFT, expand=True, fill=mtk.X) frame.pack(fill=mtk.X, pady=5, anchor="w") return frame
def create_root(self): """ Description ----------- Sets up all the parameters for the gui (text, buttons, entry boxes, etc.) Returns ------- None """ self.root = tk.Tk() self.root.title('Ultra Deluxe Focus Control Hub EXTREME') self.root.geometry('430x140') connection_text = tk.Label(self.root, text='The focuser is connected to: ') connection_text.grid(row=1, column=1) self.comport_var = tk.StringVar() self.comport_var.set(self.focuser.comport) self.comport = tk.Label(self.root, textvariable=self.comport_var) self.comport.grid(row=1, column=2) self.position = tk.IntVar() self.position.set(self.focuser.position) position_msg = tk.Label(self.root, text='The current position is: ') position_msg.grid(row=2, column=1) self.position_text = tk.Label(self.root, textvariable=self.position) self.position_text.grid(row=2, column=2) self.delta = tk.IntVar() self.delta.set(config_reader.get_config().initial_focus_delta) delta_entry = tk.Entry(self.root, textvariable=self.delta, width=5) delta_entry.grid(row=3, column=2) button_frame = tk.Frame(self.root) self.move_in = tk.Button( button_frame, text='MOVE IN', state=tk.DISABLED, command=lambda: self.move_in_cmd(self.delta.get())) self.move_out = tk.Button( button_frame, text='MOVE OUT', state=tk.DISABLED, command=lambda: self.move_out_cmd(self.delta.get())) button_frame.grid(row=3, column=1, sticky="nsew", pady=10, padx=20) self.move_in.pack(side="left") self.move_out.pack(side="right") abort = tk.Button(self.root, text='ABORT', command=self.abort_cmd, width=15) abort.grid(row=4, column=1, columnspan=2)
def create_widgets(self): self.username = tk.StringVar() self.username.set("Enter Your Username Here") self.user_entry = tk.Entry(self, textvariable=self.username) self.user_entry.pack(side="top") self.user_entry.bind('<Key-Return>', self.create_user) self.user_entry.bind('<Key-Return>', self.pick_pokemon_with_image, '+') self.user_entry.bind('<Key-Return>', self.display_image, '+') self.user_entry.bind('<Key-Return>', self.replace_user_with_guess, '+') self.quit_button = tk.Button(self, text="QUIT", fg="red", command=self.quit) self.quit_button.pack(side="bottom")
def __init__(self, model, tkroot): self.dobleroot = tkroot #self.dobleroot.withdraw() #self.dobleroot.hide() self.root = tk.Toplevel(self.dobleroot) self.model = model self.botones = ['direccion', 'puerto', 'conectar'] self.error = tk.StringVar() self.inicializarFrames() self.inicializarBotones() self.cargarImagen() self.configurarEventos() self.cargarBotones() self.textlDireccionIP.focus() return
def app(): # initialise a window. root = tk.Tk() root.config(background='white') root.geometry("1000x700") lab = tk.Label(root, text="Sismografo", bg='white').pack() fig = Figure() ax = fig.add_subplot(111) ax.set_xlabel("X axis") ax.set_ylabel("Y axis") # fig = plt.figure(1) # plt.ion() graph = FigureCanvasTkAgg(fig, master=root) graph.get_tk_widget().pack(side="top", fill='both', expand=True) variable = tk.StringVar(root) variable.set("3 V ") #defaultvalue #w=tk.OptionMenu(root, variable,"3 V ", "1 V ", "0.3 V ") #w.place(x= 300, y = 672) var = tk.StringVar(root) var.set("1ms") #option = tk.OptionMenu(root, var,"0.1ms", "1ms", "10ms") #option.place(x= 600, y = 672) def osciloscopio(): valch1_lower = np.array([], np.dtype(int)) valch1_upper = np.array([], np.dtype(int)) valch2_lower = np.array([], np.dtype(int)) valch2_upper = np.array([], np.dtype(int)) vald1 = np.array([], np.dtype(int)) vald2 = np.array([], np.dtype(int)) data_count = 0 cnt = 0 point_count = 0 #create the serial port object port = serial.Serial('/dev/ttyUSB0', 115200, timeout=0.5) while continuePlotting: #port.write(b's') #handshake with Arduino if (port.inWaiting()): # if the arduino replies value = np.array(map(ord, port.read(8000))) # read the reply if cnt == 0: cnt = cnt + 1 continue data = '' first_mask = value[:len(value)] == 255 index1 = np.flatnonzero(first_mask) + 1 valch1_upper = value[index1[:-2]] index2 = np.array(np.flatnonzero(first_mask)) + 2 valch1_lower = value[index2[:-2]] & 63 index3 = np.array(np.flatnonzero(first_mask)) + 3 valch2_upper = value[index3[:-2]] index4 = np.array(np.flatnonzero(first_mask)) + 4 valch2_lower = value[index4[:-2]] & 63 end_array = SampleOptions[var.get()] makeFig(valch1_lower, valch1_upper, valch2_lower, valch2_upper, ax, graph, variable, var) valch1_lower = np.array([], np.dtype(int)) valch1_upper = np.array([], np.dtype(int)) valch2_lower = np.array([], np.dtype(int)) valch2_upper = np.array([], np.dtype(int)) def gui_handler(): change_state() threading.Thread(target=osciloscopio).start() b = tk.Button(root, text="Start/Stop", command=gui_handler, bg="red", fg="white") b.place(x=450, y=20) b1 = tk.Button(root, text="X", command=change_channel1state, bg="blue", fg="white") b1.pack(side="left") b2 = tk.Button(root, text="Z", command=change_channel2state, bg="blue", fg="white") b2.pack(side="right") root.mainloop()
def __init__(self, parent, controller, **kwargs): tk.Frame.__init__(self, parent, **kwargs) self.controller = controller self.current_scan_Var = tk.StringVar() self.end_scan_Var = tk.StringVar() self.scan_controls_LF = ttk.LabelFrame(self, text="Scan Initialization") self.start_scan_Button = ttk.Button(self.scan_controls_LF, text="Start", state="disabled", command=self.start_scan) self.stop_scan_Button = ttk.Button(self.scan_controls_LF, text="Stop", state="disabled", command=self.stop_scan) self.quick_scan_Button = ttk.Button(self.scan_controls_LF, text="Quick Scan", state="disabled", command=self.quick_scan) self.pause_scan_Button = ttk.Button(self.scan_controls_LF, text="Pause", state="disabled", command=self.pause_scan) self.end_scan_Text = ttk.Label(self.scan_controls_LF, ) self.end_scan_Label = ttk.Label(self.scan_controls_LF, textvariable=self.end_scan_Var) self.current_scan_Label = ttk.Label(self.scan_controls_LF, textvariable=self.current_scan_Var) self.scan_controls_LF.grid( column=0, row=0, ) self.start_scan_Button.grid(column=0, row=0, ipady=10, ipadx=10, pady=10, padx=10) self.pause_scan_Button.grid(column=1, row=0, ipady=10, ipadx=10, pady=5, padx=5) self.stop_scan_Button.grid(column=2, row=0, ipady=10, ipadx=10, pady=5, padx=5) self.quick_scan_Button.grid(column=3, row=0, ipady=10, ipadx=10, pady=10, padx=10) self.end_scan_Text.grid(column=1, row=1, padx=5, pady=5) self.end_scan_Label.grid(column=2, row=1, padx=5, pady=5) self.current_scan_Label.grid(column=3, row=1, padx=5, pady=5)
def __init__(self, master, queue, endCommand): self.queue = queue self.status_label = dict() #Set up the GUI r = -1 # XBotCore Dummy r += 1 tk.Button(master, text='Run XBotCore', font='Helvetica 18 bold', command=xbot).grid(row=r, column=0, pady=20) # plugins r += 1 create_plugin_control(master, 'HomingExample', r, self.status_label) r += 1 create_plugin_control(master, 'XBotCommunicationPlugin', r, self.status_label) r += 1 create_plugin_control(master, 'HeriHand', r, self.status_label) # HeriHand control percentage = tk.StringVar(root, value='0.0') #percentage.trace("w", lambda name, index, mode, percentage=percentage: callback(percentage)) r += 1 tk.Button(master, text="Grasp", font='Calibri 12', command=lambda: heri_control("grasp", percentage)).grid( row=r, column=1, pady=20) tk.Button(master, text="Pinch", font='Calibri 12', command=lambda: heri_control("pinch", percentage)).grid( row=r, column=2) tk.Button(master, text="Tool Grasp", font='Calibri 12', command=lambda: heri_control("tool_grasp", percentage)).grid( row=r, column=3) tk.Button( master, text="Tool Trigger", font='Calibri 12', command=lambda: heri_control("tool_trigger", percentage)).grid( row=r, column=4) r += 1 tk.Label( master, text="Closure (0.0 to 1.0)", font='Calibri 12', ).grid(row=r, column=1, sticky=tk.W, padx=20, pady=20) e1 = tk.Entry(master, textvariable=percentage) e1.grid(row=r, column=2) #e1 = Entry(master) #e2 = Entry(master) # CI b = tk.Button(master, text='Cartesian Interface', font='Helvetica 12 bold', command=lambda: cartesian_interface()) r += 1 b.grid(row=r, column=0, rowspan=2, pady=20) b.config(bg='cyan') v = tk.IntVar() c1 = tk.Radiobutton(master, text='WheeledMotion', font='Helvetica 12', variable=v, value=0, command=lambda: load_controller('WheeledMotion')) c1.grid(row=r, column=1, pady=20, sticky=tk.W) r += 1 c2 = tk.Radiobutton(master, text='OpenSot', font='Helvetica 12', variable=v, value=1, command=lambda: load_controller('OpenSot')) c2.grid(row=r, column=1, sticky=tk.W) #Quit tk.Button(master, text='Quit', font='Helvetica 12', command=endCommand).grid(column=0, pady=20)
def __init__(self, inputDict=None, debug=False): self.inputDict = inputDict self.debug = debug self.rxd = [] self.txd = [] self.window = tk.Tk() self.window.title(window_title) self.window.geometry(window_size) self.right_frame = tk.Frame(self.window, width=450, height=100) self.left_frame = tk.Frame(self.window, width=250, height=100) self.corner_frame = tk.Frame(self.window, width=100, height=20) self.extra_frame = tk.Frame(self.window, width=30, height=100) self.window.grid_columnconfigure(1, weight=1) self.right_frame.grid(row=0, column=1) self.left_frame.grid(row=0, column=0, sticky="nsew") self.corner_frame.grid(row=1, column=0, sticky="sw") self.extra_frame.grid(row=0, column=2) # textbot for rx self.rx_box_scrollbar = tk.Scrollbar(self.left_frame) self.rx_box_text = tk.Text(self.left_frame, height=rx_textbox_height, width=rx_textbox_width) self.rx_box_scrollbar.grid(column=1, row=0, sticky=tk.N + tk.S + tk.W) self.rx_box_text.grid(column=0, row=0) self.rx_box_scrollbar.config(command=self.rx_box_text.yview) self.rx_box_text.config(yscrollcommand=self.rx_box_scrollbar.set) # rx button self.receive_start_button = tk.Button(self.right_frame, text="Start RX", command=self.receive) self.receive_start_button.grid(column=0, row=0, pady=5) # clear rx box windows button self.clear_button = tk.Button(self.right_frame, text="Clear", command=self.clear) self.clear_button.grid(column=0, row=1, pady=5) # tx button self.transmit_start_button = tk.Button(self.corner_frame, text="Start TX", command=self.transmit) self.transmit_start_button.grid(column=2, row=0) # tx message self.tx_msg = tk.Entry(self.corner_frame, width=tx_msg_width) self.tx_msg.grid(column=1, row=0) # tx label self.txlbl = tk.Label(self.corner_frame, text="TX Message:") self.txlbl.grid(column=0, row=0) # rx channel button self.rx_channel_button = tk.Button(self.right_frame, text="Set RX channel", command=self.setRXchannel) self.rx_channel_button.grid(column=1, row=3, pady=5) # rx channel self.rx_channel = tk.Entry(self.right_frame, width=10) self.rx_channel.grid(column=1, row=4, pady=5) # tx channel button self.tx_channel_button = tk.Button(self.right_frame, text="Set TX channel", command=self.setTXchannel) self.tx_channel_button.grid(column=0, row=3, pady=5) # tx channel self.tx_channel = tk.Entry(self.right_frame, width=10) self.tx_channel.grid(column=0, row=4, pady=5) # reset button self.reset_button = tk.Button(self.right_frame, text="Reset Device", command=self.reset) self.reset_button.grid(column=0, row=2, pady=5) # opMode droplist and button OPTIONS = [ "NORMAL_MODE", "SLEEP_MODE", "INTERNAL_LOOPBACK_MODE", "LISTEN_ONLY_MODE", "CONFIGURATION_MODE", "EXTERNAL_LOOPBACK_MODE", "CLASSIC_MODE", "RESTRICTED_MODE", "INVALID_MODE" ] self.droplist = tk.StringVar(self.left_frame) self.droplist.set(OPTIONS[0]) # default value w = tk.OptionMenu(self.right_frame, self.droplist, *OPTIONS) w.grid(column=1, row=1, padx=5) self.opmode_button = tk.Button(self.right_frame, text="Set config mode", command=self.changemode) self.opmode_button.grid(column=1, row=2, pady=5) # stop button self.stop_button = tk.Button(self.right_frame, text="STOP", command=self.stop) self.stop_button.grid(column=1, row=0, pady=5) # connect button self.connect_button = tk.Button(self.extra_frame, text="CONNECT", command=self.connect) self.connect_button.grid(column=0, row=2, pady=5) # enlarge self.connect_button.config(height=3, width=15) # bit time button self.bittime = tk.Button(self.extra_frame, text="BIT TIME", command=self.bittime) self.bittime.grid(column=0, row=3, pady=5) # bit time droplist OPTIONS_bit = ["500k_2M", "500k_4M"] self.droplist_bit = tk.StringVar(self.extra_frame) self.droplist_bit.set(OPTIONS_bit[0]) # default value w = tk.OptionMenu(self.extra_frame, self.droplist_bit, *OPTIONS_bit) w.grid(column=0, row=4, padx=5) #self.droplist_bit.grid(column=0, row=4, pady=5) # dlc droplist and button OPTIONS_dlc = [ "CAN_DLC_0", "CAN_DLC_1", "CAN_DLC_2", "CAN_DLC_3", "CAN_DLC_4", "CAN_DLC_5", "CAN_DLC_6", "CAN_DLC_7", "CAN_DLC_8", "CAN_DLC_12", "CAN_DLC_16", "CAN_DLC_20", "CAN_DLC_24", "CAN_DLC_32", "CAN_DLC_48", "CAN_DLC_64" ] self.droplist_dlc = tk.StringVar(self.extra_frame) self.droplist_dlc.set(OPTIONS_dlc[-1]) # default value w_dlc = tk.OptionMenu(self.extra_frame, self.droplist_dlc, *OPTIONS_dlc) w_dlc.grid(column=0, row=0, padx=5) self.dlc_button = tk.Button(self.extra_frame, text="Set DLC", command=self.changedlc) self.dlc_button.grid(column=0, row=1, pady=5) self.canfd = None if self.debug: # self.window.after(1000, self.dummy_main) pass else: try: self.connect() except RuntimeError: self.rx_box_text.insert( tk.END, "Device not ready. Connect manually." + '\n') finally: #self.window.after(10, self.main) self.main() self.window.mainloop()