def _tk_initialize(self): self._root = Tk.Tk() # Add number label. self._label_number = Tk.Label(self._root, text="<number>") self._label_number.pack() # TODO understand meaning. # Add batch size label. self._label_batch_shape = Tk.Label(self._root, text="<batch shape>") self._label_batch_shape.pack() # Add figures. self._frame = Tk.Frame(self._root) k_max = 2 * 4 * 4 * self._nb_channels for k in range(0, k_max): self._figures[k] = Figure(figsize=(0.5, 0.5), dpi=100) self._axes[k] = self._figures[k].add_subplot(1, 1, 1) self._axes[k].set_ylim(-50.0, +50.0) self._figure_canvasses[k] = FigureCanvasTkAgg(self._figures[k], master=self._frame) self._figure_canvasses[k].show() self._backgrounds[k] = self._figure_canvasses[k].copy_from_bbox(self._axes[k].bbox) x = np.linspace(0.0, 1.0, num=self._nb_samples / 8) y = np.zeros_like(x) self._lines[k], = self._axes[k].plot(x, y) # self._figure_canvasses[k].get_tk_widget().pack() nb_columns = 2 * 2 * 2 * 3 self._figure_canvasses[k].get_tk_widget().grid(row=int(k / nb_columns), column=(k % nb_columns)) self._frame.pack() self._root.update() return
def main(): """ Begins the program and starts up the login window Calls the necessary functions to create the window and Binds controls and buttons in order to et to the next window """ login_root = tk.Tk() login_root.wm_title("Login to Server") url = tk.Label(login_root, text="URL: ") username = tk.Label(login_root, text="Username: "******"Password: "******"IP (XX-XX-XXX-XXX): ") entry_url = tk.Entry(login_root, width=30) entry_ip = tk.Entry(login_root, width=30) entry_user = tk.Entry(login_root, width=30) entry_pass = tk.Entry(login_root, show="*", width=30) url.grid(row=0, sticky=tk.E) ip.grid(row=1, sticky=tk.E) username.grid(row=2, sticky=tk.E) password.grid(row=3, sticky=tk.E) entry_url.grid(row=0, column=1, sticky=tk.E) entry_ip.grid(row=1, column=1, sticky=tk.E) entry_user.grid(row=2, column=1, sticky=tk.E) entry_pass.grid(row=3, column=1, sticky=tk.E) global attempts login_root.bind( "<Return>", lambda x: checkcreds(login_root, entry_url.get(), entry_user.get(), entry_pass.get(), entry_ip.get())) submit = tk.Button(login_root, text="Login", command=lambda: checkcreds(login_root, entry_url.get( ), entry_user.get(), entry_pass.get(), entry_ip.get())) submit.grid(row=4, columnspan=2) login_root.mainloop()
def __init__(self, loop=None, interval=1 / 20): self.window = tk.Tk() self.interval = interval self.window.title(Config.gui_title) self.tab_controller: Notebook = ttk.Notebook(self.window) self.menu_controller = Menu(self.window) self._loop = asyncio.get_event_loop() if loop == None else loop self._running = True self._initialize()
def __init__(self): self.windows = [] self.ok = True #self.mutex = Lock() self.removeWindows = [] self.blockingWindows = [] ### create main manager tk context (root) self.root = mtk.Tk() ### make the main context invisible, (it is there, but nobody sees it) self.root.withdraw()
def __init__(self): # 窗口初始化 self.windows = tk.Tk() # 生成窗口 self.windows.title('project') self.windows.geometry('300x300') # 设置窗口尺寸 # 创建并设置按钮 self.show_tag_bt = tk.Button(master=self.windows, text='显示tag比例', command=self.show_img) self.show_tag_bt.pack(pady=20) self.find_tag_bt = tk.Button(master=self.windows, text='查找关联tag比例',command=self.show_tag) self.find_tag_bt.pack(pady=20) self.windows.mainloop()
def __init__(self, **data): self.show_win = tk.Tk() self.show_win.title('tag比例') self.show_win.protocol("WM_DELETE_WINDOW", self.show_win.quit()) self.fig = Figure(figsize=(10, 8), dpi=100) # 设置画布绘制时需要的参数绘制的尺寸与分辨率 self.sub_plot = self.fig.add_subplot(111) # 设置绘制的图的位置 self.ok_bt = tk.Button(master=self.show_win, text='确定', command=self.ok, padx=50).pack(side=tk.BOTTOM) self.draw(**data) self.show_win.mainloop()
def __init__(self): self.showTagWin = tk.Tk() self.showTagWin.title('查找tag') self.showTagWin.geometry('300x200') self.showTagWin.protocol("WM_DELETE_WINDOW", self.showTagWin.quit()) self.tag_input_lb = tk.Label(master=self.showTagWin, text='请输入tag:') self.tag_input_lb.pack(side=tk.LEFT, padx=5, pady=20) self.tag_input_txt = tk.Entry(master=self.showTagWin) self.tag_input_txt.pack(side=tk.LEFT, padx=5, pady=20) self.show_bt = tk.Button(master=self.showTagWin, text='显示', command=self.find) self.show_bt.pack(side=tk.LEFT, padx=10, pady=50) self.showTagWin.mainloop()
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 Input3(Id): root = tk.Tk() root.withdraw() file_path = filedialog.askopenfilename() book = xlrd.open_workbook(file_path) list = book.sheets() print(list) sheet_names = book.sheet_names() print(sheet_names) print(len(sheet_names[0])) try: conn = pymysql.connect(host='127.0.0.1', user='******', passwd='', db='arrangement', port=3306, charset='utf8') cur = conn.cursor() query = 'insert into course(course_code,course_name,teachingteacher,istest,iscomputer,year,month,day,time,teacher_id,str_time) values(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);' for i in sheet_names: sheet_i = book.sheet_by_name(i) for r in range(1, sheet_i.nrows): a1 = sheet_i.cell(r, 0).value a2 = sheet_i.cell(r, 1).value a3 = sheet_i.cell(r, 2).value a4 = int(sheet_i.cell(r, 3).value) a5 = int(sheet_i.cell(r, 4).value) a6 = int(sheet_i.cell(r, 5).value) a7 = int(sheet_i.cell(r, 6).value) a8 = int(sheet_i.cell(r, 7).value) a9 = int(sheet_i.cell(r, 8).value) a10 = sheet_i.cell(r, 9).value t = '8: 10 - 10: 10' if int(a9) == 1: t = '8: 10 - 10: 10' elif int(a9) == 2: t = '10: 40 - 12: 40' elif int(a9) == 3: t = '14: 00 - 16: 00' a11 = str(a6) + '年' + str(a7) + '月' + str(a8) + '日 ' + t values = (a1, a2, a3, int(a4), int(a5), int(a6), int(a7), int(a8), int(a9), a10, a11) cur.execute(query, values) cur.close() conn.commit() conn.close() except Exception as e: flash(e) flash("导入成功") root.mainloop() return render_template('Input3.html', Id=Id)
def postlogin(): """ Called after login is complete Creates all of the threads and widgets on the window This is the main window of the gui """ root = tk.Tk() root.wm_title("AutoLogin_v1.0") frame = tk.Frame(root) frame.pack() createwindow(root) updatescreen(info) createscanner() root.mainloop()
def __init__(self,pid = None): self.closed = False self.pid = PID(1.2,1,0.001) if pid is not None: self.pid = pid #how many inputs are in the graph at a time self.x_interval = 30 self.output = 0 self.x = [] self.y = [] self.start = 0 self.line = None self.root = Tk.Tk() self.root.title("Brought to you by Your Mom and co.") fig = plt.Figure() #bunch of labels & their position on the grid. play around to figure it out self.error_label = Tk.Label(self.root,text= "Your Mom") self.error_label.grid(column = 5, row = 0) p_label = Tk.Label(self.root,text= "P Constant").grid(column = 0, row = 0) i_label = Tk.Label(self.root,text= "I Constant").grid(column = 1, row = 0) d_label = Tk.Label(self.root,text= "D Constant").grid(column = 2, row = 0) pid_label = Tk.Label(self.root,text= "PID Setpoint").grid(column = 3, row = 0) #we only care about the text in the box. All other elements work on their own with Tkinter self.p_constant = Tk.Text(self.root,height = 2, width = 10, bg = "light yellow") self.p_constant.grid(column = 0, row = 1) self.i_constant = Tk.Text(self.root,height = 2, width = 10, bg = "light yellow") self.i_constant.grid(column = 1, row = 1) self.d_constant = Tk.Text(self.root,height = 2, width = 10, bg = "light yellow") self.d_constant.grid(column = 2, row = 1) self.sp = Tk.Text(self.root,height = 2, width = 10, bg = "light yellow") self.sp.grid(column = 3, row = 1) changePID = Tk.Button(self.root,text = "Change PID value", command = self.change_PID).grid(column = 1, row = 2) self.canvas = FigureCanvasTkAgg(fig,master = self.root) self.canvas.get_tk_widget().grid(column = 4, row = 3) #create a plot and put it into matplot's figure. 111 divides into 1 row & 1 column of plot #refers to the online doc. But yeah, we only need 1 plot. ax = fig.add_subplot(111) #set x and y axis. This can be put into variable in future sprint. ax.set_ylim([-180,180]) ax.set_xlim([0,self.x_interval]) #matplot automatically draw the line from a list of x and y values. line need to be redraw again and again self.line, = ax.plot(self.x, self.y) def on_closing(): self.closed = True self.root.destroy() self.root.protocol("WM_DELETE_WINDOW", on_closing)
def select_files(self): """ Display a dialog box to select the files. :return: List of all the files selected. """ # Dialog to ask for a file to select root = mtTkinter.Tk() root.overrideredirect(True) # Used to Bring window to front and focused root.geometry('0x0+0+0') # Used to Bring window to front and focused root.focus_force() # Used to Bring window to front and focused filetypes = [("DB files", "*.db"), ("ENS Files", "*.ens"), ("BIN Files", "*.bin"), ('All Files', '*.*')] self.file_paths = filedialog.askopenfilenames(parent=root, title="Select Binary Files to Playback", filetypes=filetypes) root.withdraw() return self.file_paths
def __init__(self): print('search all ips on network') self.root = mtTkinter.Tk() self.root.title('available IP\'s') self.root.resizable(width=False, height=False) self.frame = mtTkinter.Frame(self.root, relief=mtTkinter.FLAT, bd=1) self.frame.grid(row=0, column=0, padx=2, pady=2, sticky=mtTkinter.N + mtTkinter.W + mtTkinter.E) self.frame.columnconfigure(0, weight=1) self.listbox = mtTkinter.Listbox(self.frame, width=100, height=15) self.listbox.grid(row=1,column=0, sticky="ew", padx=2, pady=2) # listbox scrollbar self.listboxScrollbar = mtTkinter.Scrollbar(self.frame, orient="vertical") self.listboxScrollbar.grid(row=1, column=1, padx=2,pady=2,sticky="ns") self.listboxScrollbar.config(command=self.listbox.yview) self.listbox.config(yscrollcommand=self.listboxScrollbar.set) #create log textbox self.log = mtTkinter.Text(self.frame, height=15, width=100) self.log.grid(row=2, column=0, sticky="ew", padx=2, pady=2) self.log.config(state=mtTkinter.DISABLED) # log scrollbar self.logScrollbar = mtTkinter.Scrollbar(self.frame, orient="vertical") self.logScrollbar.grid(row=2, column=1, padx=2, pady=2, sticky="ns") self.logScrollbar.config(command=self.log.yview) self.log.config(yscrollcommand=self.logScrollbar.set) # update list button self.commandButton = mtTkinter.Button(self.frame, text="update connections list", command=self.update_connection_list) self.commandButton.grid(row=3, column=0, sticky="ew") self.openStatsWin = {} self.update_connection_list() self.log.delete("1.0", mtTkinter.END) self.listbox.bind("<Double-Button-1>", self.clicked_on_ip) self.root.protocol("WM_DELETE_WINDOW", self.exit) self.root.mainloop()
def __init__(self, manager, key, threaded=False, size="100x100", bg="light gray"): super(Window, self).__init__(key) self.manager = manager #self.thread.start() self.root = mtk.Tk() self.root.protocol("WM_DELETE_WINDOW", self.close) self.root.title(self.key) self.root.geometry(size) self.root.config(bg=bg) ### create first layout self.layout = Vertical("layout", padding=5) self.ok = True self.isClosing = False
def Input4(Id): root = tk.Tk() root.withdraw() file_path = filedialog.askopenfilename() book = xlrd.open_workbook(file_path) list = book.sheets() print(list) sheet_names = book.sheet_names() print(sheet_names) print(len(sheet_names[0])) try: conn = pymysql.connect(host='127.0.0.1', user='******', passwd='', db='arrangement', port=3306, charset='utf8') cur = conn.cursor() query = 'insert into study(sId,course_code,sname,grade,sclass,course_name) values(%s, %s, %s, %s, %s, %s);' for i in sheet_names: sheet_i = book.sheet_by_name(i) for r in range(1, sheet_i.nrows): a1 = sheet_i.cell(r, 0).value a2 = sheet_i.cell(r, 1).value a3 = sheet_i.cell(r, 2).value a4 = sheet_i.cell(r, 3).value a5 = sheet_i.cell(r, 4).value a6 = sheet_i.cell(r, 5).value values = (a1, a2, a3, a4, a5, a6) cur.execute(query, values) cur.close() conn.commit() conn.close() except Exception as e: flash(e) flash("导入成功") root.mainloop() return render_template('Input4.html', Id=Id)
dialog.Destroy() img = Image.open(filepath) width, height = img.size scale = width / height if scale > 0: height = CANVAS_SIZE / scale else: height = CANVAS_SIZE * scale img = ImageTk.PhotoImage(img.resize((CANVAS_SIZE, round(height)))) canv.create_image(CANVAS_SIZE/2, CANVAS_SIZE/2, image=img) if round(pr.predict(filepath)) == 1: messagebox.showinfo("Prediction", "This is a dog.") else: messagebox.showinfo("Prediction", "This is a cat.") # Creating the main window window = tk.Tk() window.geometry("600x600") window.resizable(0, 0) window.title("Recognizing Dogs And Cats") window.configure(background='#94fffb') load_image_button = tk.Button(window, text="Load The Image And See The Prediction!", command=load_and_predict, width=40, background='#33ff3a') load_image_button.place(relx=0.5, rely=0.075, anchor='center') canv = tk.Canvas(window, width=CANVAS_SIZE, height=CANVAS_SIZE, bg='white') canv.place(relx=0.5, rely=0.5, anchor='center') exit_button = tk.Button(window, text="Exit", command=exit, width=20, background='#fa2d2d') exit_button.place(relx=0.5, rely=0.925, anchor='center') tk.mainloop()
def creatUI(self): self.window = tk.Tk() self.window.title("GDMapPoi") # 设置窗口大小和位置 self.window.geometry('800x650+500+50') # 设置字体 self.font = tf.Font(size=10) # poi搜索 # self.oneSearch = tk.Label(self.window, text="Poi搜索", font=self.font) # self.oneSearch.place(x=20, y=50) # 地 区 self.label_totals = tk.LabelFrame(self.window, text="地 区", font=self.font, padx=10, pady=10) self.label_totals.place(x=20, y=50) self.window_entry_cities = scrolledtext.ScrolledText(self.label_totals, width=20, height=5, wrap=tk.WORD, font=tf.Font(size=12)) self.window_entry_cities.grid() # 关键词 self.label_keywords = tk.LabelFrame(self.window, text="关键词", font=self.font, padx=10, pady=10) self.label_keywords.place(x=250, y=50) self.window_entry_keywords = scrolledtext.ScrolledText(self.label_keywords, width=20, height=5, wrap=tk.WORD, font=tf.Font(size=12)) self.window_entry_keywords.grid() # 高德API接口KEY self.label_totals = tk.LabelFrame(self.window, text="高德API接口KEY", font=self.font, padx=10, pady=10) self.label_totals.place(x=550, y=80) self.window_entry_cities = scrolledtext.ScrolledText(self.label_totals, width=20, height=2, wrap=tk.WORD, font=tf.Font(size=11)) self.window_entry_cities.grid() # 数据量 self.label_totals = tk.LabelFrame(self.window, text="数据量", font=self.font, padx=10, pady=10) self.label_totals.place(x=550, y=200) self.window_entry_totals = scrolledtext.ScrolledText(self.label_totals, width=20, height=2, wrap=tk.WORD, font=tf.Font(size=11)) self.window_entry_totals.grid() # # 查询button # self.btn_seacch = tk.Button(self.window, text="查询", font=self.font, # ) # self.btn_seacch.place(x=630, y=500, width=150, height=30) # # # 导出excel # self.btn_excel = tk.Button(self.window, text="导出文件", font=self.font, # ) # self.btn_excel.place(x=630, y=540, width=150, height=30) # # 数据展示 self.label_show_data = tk.LabelFrame(self.window, text="数据展示", font=self.font, padx=10, pady=10) self.label_show_data.place(x=20, y=200) self.window_showdata = scrolledtext.ScrolledText(self.label_show_data, width=57, height=20, wrap=tk.WORD, font=tf.Font(size=11)) # self.window_showdata.grid() # self.scrollbar = tk.Scrollbar(self.window_showdata) # self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y) title = ['1', '2', '3', '4', '5', '6', '7'] self.box = ttk.Treeview(self.window_showdata, columns=title, show='headings') self.box.place(x=0, y=0, height=20) # self.box.grid() self.box.column('1', width=50, anchor='center') self.box.column('2', width=50, anchor='center') self.box.column('3', width=100, anchor='center') self.box.column('4', width=100, anchor='center') self.box.column('5', width=100, anchor='center') self.box.column('6', width=50, anchor='center') self.box.column('7', width=50, anchor='center') self.box.heading('1', text='省份') self.box.heading('2', text='城市') self.box.heading('3', text='名称') self.box.heading('4', text='地址') self.box.heading('5', text='电话') self.box.heading('6', text='经度') self.box.heading('7', text='纬度') self.window_showdata.grid()
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()
plt.ion() rospy.init_node('listener', anonymous=True) rospy.Subscriber("/trajectory_viewer_main/trajectory_plot", trajPlot, callback) fig, ax = plt.subplots() ax.set_title('Trajectory Viewer') ax.set_xlabel('Joint 1') ax.set_ylabel('Trajectory Point Index') gp = Graph_Plotter(fig, ax) """ use mttkinter to avoid main thread issues """ top = tk.Tk() #Code to add widgets goes here angle_label = tk.Label(top, text="Joint Angle") angle_label.grid(row=0, column=0) #angle_label.pack(side=Tkinter.LEFT) angle_value = tk.Entry(top, bd=5) #angle_value.pack(side=Tkinter.RIGHT) angle_value.grid(row=0, column=1) point_label = tk.Label(top, text="Trajectory Point Index") #point_label.pack(side=Tkinter.LEFT) point_label.grid(row=1, column=0) point_value = tk.Entry(top, bd=5) #point_value.pack(side=Tkinter.RIGHT) point_value.grid(row=1, column=1)
def creatUI(self): self.window = tk.Tk() self.window.title("GDMapPoi") # 设置窗口大小和位置 self.window.geometry('960x640+500+50') # poi搜索 # self.oneSearch = tk.Label(self.window, text="Poi搜索", font=self.font) # self.oneSearch.place(x=20, y=50) # 高德API接口KEY self.label_api_key = tk.Label(self.window, text="高德API接口KEY", font=("思源黑体", 11, "bold")) self.label_api_key.place(x=20, y=20, width=120, height=25) self.entry_api_key = tk.Entry(self.window, font=("思源黑体", 11)) # self.entry_api_key["values"] = ("b9cb3ad7476d6d6b977340ebdae2f976") self.entry_api_key.place(x=20, y=50, width=450, height=25) # 数据量 self.label_totals = tk.Label(self.window, text="数据量", font=("思源黑体", 11, "bold")) self.label_totals.place(x=495, y=50, width=50, height=25) self.entry_totals = tk.Entry(self.window, font=("思源黑体", 11)) self.entry_totals.place(x=555, y=50, width=100, height=25) # 地 区 self.label_cities = tk.Label(self.window, text="地 区", font=("思源黑体", 11, "bold")) self.label_cities.place(x=740, y=20, width=50, height=25) self.entry_cities = scrolledtext.ScrolledText(self.window, font=("思源黑体", 11)) self.entry_cities.place(x=740, y=50, width=170, height=195) # 关键词 self.label_keywords = tk.Label(self.window, text="关键词", font=("思源黑体", 11, "bold")) self.label_keywords.place(x=740, y=245, width=50, height=25) self.entry_keywords = scrolledtext.ScrolledText(self.window, font=("思源黑体", 11)) self.entry_keywords.place(x=740, y=275, width=170, height=195) # 查询button self.btn_seacch = tk.Button( self.window, text="查询", font=("思源黑体", 11, "bold"), command=lambda: self.thread_it(self.start_task)) self.btn_seacch.place(x=740, y=510, width=150, height=30) # 导出excel self.btn_excel = tk.Button( self.window, text="导出Excel", font=("思源黑体", 11, "bold"), command=lambda: self.thread_it(self.save2excel)) self.btn_excel.place(x=740, y=550, width=150, height=30) # 数据展示 title = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] self.box = ttk.Treeview(self.window, columns=title, show='headings') # style = ttk.Style() # style.configure("Treeview.Heading", font=("思源黑体", 11, "bold")) self.box.place(x=20, y=100, width=700, height=505) self.box.column('1', width=50, anchor='center') self.box.column('2', width=50, anchor='center') self.box.column('3', width=50, anchor='center') self.box.column('4', width=150, anchor='center') self.box.column('5', width=150, anchor='center') self.box.column('6', width=150, anchor='center') self.box.column('7', width=100, anchor='center') self.box.column('8', width=80, anchor='center') self.box.column('9', width=80, anchor='center') self.box.heading('1', text='省份') self.box.heading('2', text='城市') self.box.heading('3', text='区域') self.box.heading('4', text='名称') self.box.heading('5', text='标签') self.box.heading('6', text='地址') self.box.heading('7', text='电话') self.box.heading('8', text='经度') self.box.heading('9', text='纬度') self.VScroll1 = Scrollbar(self.box, orient='vertical', command=self.box.yview) self.VScroll1.pack(side="right", fill="y") self.VScroll2 = Scrollbar(self.box, orient='horizontal', command=self.box.xview) self.VScroll2.pack(side="bottom", fill="x") # self.VScroll2.place(relx=0.971, rely=0.028, relwidth=0.024, relheight=0.958) # self.VScroll1.place(relx=0.971, rely=0.028, relwidth=0.024, relheight=0.958) # 给treeview添加配置 self.box.configure(yscrollcommand=self.VScroll1.set) self.box.configure(xscrollcommand=self.VScroll2.set)
for answer in question.find_elements_by_xpath( "div[@class='test-margin']/div/label"): webAnswer = re.sub(r"([ABCD][\.、])|(\(true\))|\(false\)", "", answer.text) if webAnswer in correctAnswer: answer.click() self.logtext.insert(mtk.END, "答题结束.\n") def start(self): self.login() self.studyPage() self.doExam() def stop(self): if self.browser: self.browser.quit() os._exit(0) @staticmethod def thread_it(func, *args): t = threading.Thread(target=func, args=args) t.setDaemon(True) t.start() if __name__ == '__main__': root = mtk.Tk() Application(root) root.mainloop()
def __init__(self): self.win = tk.Tk() self.win.title("Ayna Downloader") self.tab_controller: Notebook = ttk.Notebook(self.win) self.menuc_controller = Menu(self.win) self._initialize()
def __init__(self, title): self.root = mtk.Tk() self.root.geometry("340x500") self.root.title(f"[{title}]下载进度")
def __init__(self): self.window = tK.Tk() self.window.title("C. Elegans Connectome Monitor") self.window.configure(background='white') self.neurons = dict() self.robot_enabling = True # Placeholder tK.Label(self.window, bg='white').grid(column=50, row=100, padx=10, pady=2) tK.Label(self.window, text="C. ELEGANS CONNECTOME MONITOR", fg='cyan3', bg='black', font=('Arial', 16, 'bold'), width=50, height=1)\ .grid(column=0, row=0, columnspan=30, pady=10) tK.Label(self.window, text="Simulation time:", fg='black', bg='white', width=15, anchor=tK.W, font=('Arial', 12))\ .grid(column=0, row=1, padx=(20, 0)) self.time_label = tK.Label(self.window, text="4.4s", fg='black', bg='white', width=15, anchor=tK.E, font=('Arial', 12, 'bold')) self.time_label.grid(column=1, row=1, padx=(0, 20)) tK.Label(self.window, text="Robot State:", fg='black', bg='white', width=15, anchor=tK.W, font=('Arial', 12))\ .grid(column=0, row=2, padx=(20, 0)) self.robot_status = tK.Label(self.window, text="DISCONNECTED", fg='tomato', bg='white', width=15, anchor=tK.E, font=('Arial', 12, 'bold')) self.robot_status.grid(column=1, row=2, padx=(0, 20)) tK.Label(self.window, text="Robot Control:", fg='black', bg='white', width=15, anchor=tK.W, font=('Arial', 12))\ .grid(column=0, row=3, padx=(20, 0) ) self.enable_robot_btn = tK.Button(self.window, text="Enable", width=15, justify=tK.CENTER, font=('Arial', 8, 'bold italic'), command=self.enable_robot, state=tK.DISABLED) self.enable_robot_btn.grid(column=1, row=3) self.disable_robot_btn = tK.Button(self.window, text="Disable", width=15, justify=tK.CENTER, font=('Arial', 8, 'bold italic'), command=self.disable_robot) self.disable_robot_btn.grid(column=1, row=4) # Borders tK.Label(self.window, bd=1, relief=tK.SOLID, width=45, height=14, bg='white').grid(column=0, row=5, columnspan=2, rowspan=11) tK.Label(self.window, text="Mechanosensation", fg='black', bg='white', width=15, anchor=tK.W, font=('Arial', 12, 'italic')) \ .grid(column=0, row=6, padx=(20, 0) ) self.nose_s_touch_active = False self.nose_s_touch_btn = tK.Button(self.window, text="Nose Touch (Soft)", width=15) self.nose_s_touch_btn.grid(column=0, row=7, columnspan=2) self.nose_s_touch_btn.bind( '<ButtonPress-1>', partial(self.update_nose_s_touch, state=True)) self.nose_s_touch_btn.bind( '<ButtonRelease-1>', partial(self.update_nose_s_touch, state=False)) self.nose_h_touch_active = False self.nose_h_touch_btn = tK.Button(self.window, text="Nose Touch (Harsh)", width=15) self.nose_h_touch_btn.grid(column=0, row=9, columnspan=2) self.nose_h_touch_btn.bind( '<ButtonPress-1>', partial(self.update_nose_h_touch, state=True)) self.nose_h_touch_btn.bind( '<ButtonRelease-1>', partial(self.update_nose_h_touch, state=False)) self.l_side_touch_active = False self.l_side_touch_btn = tK.Button(self.window, text="L. Side Touch", width=15) self.l_side_touch_btn.grid(column=0, row=11) self.l_side_touch_btn.bind( '<ButtonPress-1>', partial(self.update_l_side_touch, state=True)) self.l_side_touch_btn.bind( '<ButtonRelease-1>', partial(self.update_l_side_touch, state=False)) self.r_side_touch_active = False self.r_side_touch_btn = tK.Button(self.window, text="R. Side Touch", width=15) self.r_side_touch_btn.grid(column=1, row=11) self.r_side_touch_btn.bind( '<ButtonPress-1>', partial(self.update_r_side_touch, state=True)) self.r_side_touch_btn.bind( '<ButtonRelease-1>', partial(self.update_r_side_touch, state=False)) self.tail_touch_active = False self.tail_touch_btn = tK.Button(self.window, text="Tail Touch", width=15) self.tail_touch_btn.grid(column=0, row=13, columnspan=2) self.tail_touch_btn.bind('<ButtonPress-1>', partial(self.update_tail_touch, state=True)) self.tail_touch_btn.bind('<ButtonRelease-1>', partial(self.update_tail_touch, state=False))
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()
def __init__(self): self.root = tk.Tk() self.root.withdraw()
from mttkinter import mtTkinter as mtk from tkinter.constants import * import rfid_controller import mosquitto ## Events def close(): mosquitto.stop_service() win.destroy() ## Base GUI window win = mtk.Tk() win.title("RFID Reader") win.geometry("675x475") ## Widgets tab_parent = mtk.ttk.Notebook(win) tab_rfid = mtk.ttk.Frame(tab_parent) tab_parent.add(tab_rfid, text='RFID Reader') tab_parent.pack(expand=1, fill='both') rfid_controller.load_ui(tab_rfid) # Start mosquitto server mosquitto.start_service() # Close application
def __createGUI(self): self.root = mtk.Tk() self.root.title("移动惠购用户查询工具") self.root.geometry("720x600") self.settings = mtk.LabelFrame(text="设置", fg="blue") self.settings.place(x=50, y=20, width=600, height=130) self.shopId = mtk.Label(self.settings, text="店铺 ID:") self.shopId.place(x=30, y=10, width=60, height=20) self.shopIdText = mtk.Entry(self.settings) self.shopIdText.place(x=85, y=10, width=80, height=20) self.workNo = mtk.Label(self.settings, text="工 号:") self.workNo.place(x=200, y=10, width=60, height=20) self.workNoText = mtk.Entry(self.settings) self.workNoText.place(x=260, y=10, width=80, height=20) self.semaphoreNum = mtk.Label(self.settings, text="并发数量:") self.semaphoreNum.place(x=30, y=70, width=60, height=20) self.entrySemaphoreNum = mtk.Entry(self.settings) self.entrySemaphoreNum.place(x=85, y=70, width=80, height=20) self.timeSleep = mtk.Label(self.settings, text="延迟时间:") self.timeSleep.place(x=200, y=70, width=60, height=20) self.entrySleep = mtk.Entry(self.settings) self.entrySleep.place(x=260, y=70, width=80, height=20) self.statusNow = mtk.Label(self.settings, text="当前进度:") self.statusNow.place(x=420, y=10, width=60, height=20) self.statusNowText = mtk.Label(self.settings, text="0/0") self.statusNowText.place(x=450, y=50, width=60, height=20) self.showDataBox = mtk.LabelFrame(self.root, text="数据信息", fg="blue") self.showDataBox.place(x=50, y=170, width=400, height=400) title = ['1', '2', '3', '4'] self.box = ttk.Treeview(self.showDataBox, columns=title, show='headings') self.box.place(x=20, y=15, width=360, height=340) self.box.column('1', width=50, anchor='center') self.box.column('2', width=100, anchor='center') self.box.column('3', width=50, anchor='center') self.box.column('4', width=160, anchor='center') self.box.heading('1', text='序号') self.box.heading('2', text='手机号') self.box.heading('3', text='优惠') self.box.heading('4', text='ERROR信息') self.VScroll1 = Scrollbar(self.box, orient='vertical', command=self.box.yview) self.VScroll1.pack(side="right", fill="y") self.box.configure(yscrollcommand=self.VScroll1.set) self.box.bind(sequence="<Double-Button-1>", func=lambda x: self.thread_it(self.showDetail)) self.btnBox = mtk.LabelFrame(self.root, text="任务栏", fg="blue") self.btnBox.place(x=480, y=170, width=170, height=400) self.fileBox = mtk.LabelFrame(self.btnBox) self.fileBox.place(x=15, y=30, width=140, height=120) self.loadExcel = mtk.Button( self.fileBox, text="导入Excel", command=lambda: self.thread_it(self.__loadExcel)) self.loadExcel.place(x=15, y=20, width=100, height=30) self.btnEnd = mtk.Button( self.fileBox, text="导出Excel", command=lambda: self.thread_it(self.__saveExcel)) self.btnEnd.place(x=15, y=70, width=100, height=30) self.btnBbox = mtk.LabelFrame(self.btnBox) self.btnBbox.place(x=15, y=200, width=140, height=120) self.btnStart = mtk.Button(self.btnBbox, text="开始", command=lambda: self.thread_it(self.start)) self.btnStart.place(x=15, y=20, width=100, height=30) self.btnStop = mtk.Button(self.btnBbox, text="停止", command=lambda: self.thread_it(self.stop)) self.btnStop.place(x=15, y=70, width=100, height=30)
for item in array: try: item = int(item) except: pass arrayr.append(item) return arrayr def start(threadname, x): os.system("./hello.sh") if __name__ == '__main__': #_thread.start_new_thread(start,("threadname",1)) root = tk.Tk() #全屏应用 root.attributes("-fullscreen", True) # 串口初始化 #ser=serial.Serial('COM6',115200,parity='N',stopbits=1,bytesize=8,timeout=10) #获取宽高 winwidth = root.winfo_screenwidth() winheight = root.winfo_screenheight() basedesk(root) root.mainloop() # root = tk.Tk() # img_png = tkinter.PhotoImage(file = 'banana.gif') # label_img = tkinter.Label(root, image = img_png) # label_img.pack()
if __name__ == "__main__": os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' config = tf.compat.v1.ConfigProto() config.gpu_options.allow_growth = True session = tf.compat.v1.Session(config=config) if os.path.exists(get_last_model_dir(best_model_path)): model = tf.keras.models.load_model(get_last_model_dir(best_model_path), compile=False) print("best model {} loaded!".format( get_last_model_dir(best_model_path))) else: raise FileNotFoundError("There is no model to load") master = mtk.Tk() player_moved = mtk.BooleanVar() AI_thinking = mtk.BooleanVar() finish = mtk.BooleanVar() finish.set(False) tk = mtk.Canvas(master, width=DIMENSION + MARGIN * 2, height=DIMENSION + MARGIN * 2) tk.pack() pool = ThreadPool(processes=1) PLAYER_IS_WHITE = True C_GO_FIRST = 1 if PLAYER_IS_WHITE else -1 tk.bind("<Button-1>", lambda event: mouse_clicked(event))