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 createPage(self): self.login = mtk.LabelFrame(self.root, text="登录", fg="blue") self.login.place(x=30, y=50, width=380, height=250) self.label_asino = mtk.Label(self.login, text="AsiNumber:") self.label_asino.place(x=30, y=10, width=75, height=25) self.entry_asino = mtk.Entry(self.login) self.entry_asino.place(x=120, y=10, width=220, height=25) self.label_user = mtk.Label(self.login, text="账号:") self.label_user.place(x=30, y=65, width=75, height=25) self.entry_user = mtk.Entry(self.login) self.entry_user.place(x=120, y=65, width=220, height=25) self.label_passwd = mtk.Label(self.login, text="密码:") self.label_passwd.place(x=30, y=120, width=75, height=25) self.entry_passwd = mtk.Entry(self.login, show="*") self.entry_passwd.place(x=120, y=120, width=220, height=25) self.btn_logins = mtk.Button( self.login, text="自动登录", command=lambda: self.thread_it(self.loginSelf)) self.btn_logins.place(x=40, y=170, width=100, height=30) self.btn_login = mtk.Button( self.login, text="登录", command=lambda: self.thread_it(self.loginContent)) self.btn_login.place(x=220, y=170, width=100, height=30)
def draw_card(self, x, y, card): if card is None: tk.Button(self.window, bg="black", fg="white", width=40, height=90, image=self.pixel_virtual, command=partial(self.choose_card, None)).place(x=x, y=y) tk.Label(self.window, text="?").place(x=x + 20, y=y + 45) else: if card.color == 0: for i in range(1, 5): card.color = i tk.Button(self.window, fg="white", bg=card.get_color_string(), width=40, height=90 / 4, image=self.pixel_virtual, command=partial(self.choose_card, copy.deepcopy(card))).place( x=x, y=y + 90 / 4 * (i - 1)) card.color = 0 else: tk.Button(self.window, fg="white", bg=card.get_color_string(), width=40, height=90, image=self.pixel_virtual, command=partial(self.choose_card, card)).place(x=x, y=y) tk.Label(self.window, text=card.get_value_string()).place(x=x + 10, y=y + 45)
def __createUI(self): # 博轩下载设置 self.settingsBox = mtk.LabelFrame(self.root, text="下载设置", fg="blue") self.settingsBox.place(x=20, y=20, width=260, height=250) # 网站选择 self.siteLable = mtk.Label(self.settingsBox, text="互联网平台:") self.siteLable.place(x=25, y=20, width=75, height=25) self.siteSelect = ttk.Combobox(self.settingsBox) self.siteSelect["values"] = ["360图书馆", "39康复网", "中医世家", "中医人", "中医中药秘方网", "中医中药网", "经方派", "新浪博文", "好大夫在线"] self.siteSelect.place(x=115, y=20, width=100, height=25) # 页面属性 self.siteCls = mtk.Label(self.settingsBox, text="页面选择:") self.siteCls.place(x=25, y=65, width=65, height=25) self.siteClsSelect = ttk.Combobox(self.settingsBox) self.siteClsSelect["values"] = ["列表页", "内容页"] self.siteClsSelect.place(x=115, y=65, width=100, height=25) # 链接 self.labelUrl = mtk.Label(self.settingsBox, text="链接:") self.labelUrl.place(x=25, y=110, width=40, height=25) self.urlText = mtk.Text(self.settingsBox) self.urlText.place(x=75, y=110, width=160, height=50) self.urlText.bind(sequence="<Double-Button-1>", func=lambda x: self.thread_it(self.loadErrors)) # 任务按钮 self.startBtn = mtk.Button(self.settingsBox, text="开始", command=lambda: self.thread_it(self.start)) self.startBtn.place(x=25, y=180, width=80, height=35) self.stopBtn = mtk.Button(self.settingsBox, text="停止") self.stopBtn.place(x=135, y=180, width=80, height=35)
def __createUI(self): # 日志信息 self.logBox = mtk.LabelFrame(self.root, text="日志信息", fg="blue") self.logBox.place(x=20, y=20, width=250, height=260) self.logText = scrolledtext.ScrolledText(self.logBox, fg="green") self.logText.place(x=20, y=15, width=220, height=210) # Excel数据 self.excelDataBox = mtk.LabelFrame(self.root, text="当前数据", fg="blue") self.excelDataBox.place(x=290, y=20, width=180, height=80) self.dataNum = mtk.Label(self.excelDataBox, text="当前数据数量:") self.dataNum.place(x=10, y=10, width=100, height=30) self.dataNumText = mtk.Label(self.excelDataBox, text=0) self.dataNumText.place(x=115, y=10, width=30, height=30) # taskInfo self.taskInfoBox = mtk.LabelFrame(self.root, text="启动任务", fg="blue") self.taskInfoBox.place(x=290, y=120, width=180, height=160) self.excelExportInBtn = mtk.Button(self.taskInfoBox, text="导入Excel", command=lambda: self.thread_it(self.excelExportIn)) self.excelExportInBtn.place(x=15, y=20, width=80, height=35) self.excelExportOutBtn = mtk.Button(self.taskInfoBox, text="导出Excel", command=lambda: self.thread_it(self.excelExportOut)) self.excelExportOutBtn.place(x=15, y=80, width=80, height=35) self.taskStartBtn = mtk.Button(self.taskInfoBox, text="开始", command=lambda: self.thread_it(self.start)) self.taskStartBtn.place(x=110, y=20, width=50, height=90)
def createPage(self): self.loginBox = mtk.LabelFrame(self.loginPage, text="账号登录", fg="blue") self.loginBox.place(x=30, y=30, width=300, height=280) self.userName = mtk.Label(self.loginBox, text="账号:") self.userName.place(x=20, y=20, width=50, height=30) self.userNameText = mtk.Entry(self.loginBox) self.userNameText.place(x=90, y=20, width=150, height=30) self.passWord = mtk.Label(self.loginBox, text="密码:") self.passWord.place(x=20, y=70, width=50, height=30) self.passWordText = mtk.Entry(self.loginBox) self.passWordText.place(x=90, y=70, width=150, height=30) # self.keyValue = mtk.Label(self.loginBox, text="KEY:") # self.keyValue.place(x=20, y=120, width=50, height=30) self.keyValueText = mtk.Entry(self.loginBox, show="*") self.keyValueText.place(x=90, y=120, width=150, height=30) self.loginBtn = mtk.Button(self.loginBox, text="登录", command=lambda: self.thread_it(self.login)) self.loginBtn.place(x=150, y=180, width=80, height=30) self.logoutBtn = mtk.Button(self.loginBox, text="退出", command=lambda: self.thread_it(self.stop)) self.logoutBtn.place(x=40, y=180, width=80, height=30)
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 __creatUI(self): self.box = mtk.LabelFrame(self.root) self.box.place(x=20, y=20, width=340, height=400) self.user_name = mtk.Label(self.box, text="账 号:") self.user_name.place(x=20, y=20, width=60, height=25) self.user_name_text = mtk.Entry(self.box) self.user_name_text.place(x=80, y=20, width=100, height=25) self.pass_word = mtk.Label(self.box, text="密 码:") self.pass_word.place(x=20, y=70, width=60, height=25) self.password_text = mtk.Entry(self.box) self.password_text.place(x=80, y=70, width=100, height=25) self.loginadd = mtk.Label(self.box, text="登录地:") self.loginadd.place(x=20, y=120, width=60, height=25) self.loginaddsel = ttk.Combobox(self.box) self.loginaddsel["values"] = [ "上海总部", "上海物流", "甘肃", "河北", "西北", "山西", "浙江", "安徽", "山东", "江西", "武汉", "北京", "江苏", "四川", "广东" ] self.loginaddsel.place(x=80, y=120, width=100, height=25) self.verify_code = mtk.Label(self.box, text="验证码:") self.verify_code.place(x=20, y=170, width=60, height=25) self.verify_code_text = mtk.Entry(self.box) self.verify_code_text.place(x=80, y=170, width=100, height=25) self.exam_name = mtk.Label(self.box, text="考试名称:") self.exam_name.place(x=20, y=220, width=60, height=25) self.exam_name_text = mtk.Entry(self.box) self.exam_name_text.place(x=80, y=220, width=100, height=25) self.loadbtn = mtk.Button( self.box, text="加载题型", command=lambda: self.thread_it(self.__loadExcel)) self.loadbtn.place(x=210, y=20, width=100, height=50) self.startbtn = mtk.Button(self.box, text="开始", command=lambda: self.thread_it(self.start)) self.startbtn.place(x=210, y=100, width=100, height=50) self.stopbtn = mtk.Button(self.box, text="退出", command=lambda: self.thread_it(self.stop)) self.stopbtn.place(x=210, y=180, width=100, height=50) self.logs = mtk.LabelFrame(self.box, text="信息", fg="blue") self.logs.place(x=20, y=270, width=300, height=120) self.logtext = scrolledtext.ScrolledText(self.logs, fg="green") self.logtext.place(x=20, y=10, width=270, height=80)
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 __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 createNewUI(self, taskName, taskInfo): detailWin = mtk.Toplevel(self.root) detailWin.title(taskName) detailWin.geometry("650x550") tasksInfoBox = mtk.LabelFrame(detailWin, text="任务说明:", fg="blue") tasksInfoBox.place(x=20, y=20, width=610, height=510) tasksIntro = scrolledtext.ScrolledText(tasksInfoBox, fg="green") tasksIntro.place(x=20, y=10, width=580, height=60) tasksIntro.insert( END, f"{''.join([taskInfo.get('EarnDeatile').get('detail')[j] for j in range(len(taskInfo.get('EarnDeatile').get('detail'))) if ord(taskInfo.get('EarnDeatile').get('detail')[j]) in range(65536)])}\n{taskInfo.get('EarnDeatile').get('condition')}" .replace(" ", "")) taskStep = mtk.LabelFrame(tasksInfoBox, text="任务步骤", fg="blue") taskStep.place(x=20, y=80, width=200, height=380) stepText = scrolledtext.ScrolledText(taskStep, fg="green") stepText.place(x=10, y=10, width=180, height=330) if isinstance(taskInfo.get("WjMissionDeatile"), list): totalTextList = [] for index, item in enumerate(taskInfo.get("WjMissionDeatile")): detail = item.get("detail", "") othLink = item.get("btnname", "") detailText = detail + othLink text = f"\n\nstep {index + 1}: " + ''.join([ detailText[j] for j in range(len(detailText)) if ord(detailText[j]) in range(65536) ]).strip() totalTextList.append(text) stepText.insert(END, "\n\n".join(totalTextList)) else: stepText.insert( END, f"\n\nstep 1: {taskInfo.get('WjMissionDeatile').get('msg')}") self.imageShow = mtk.LabelFrame(tasksInfoBox, text="图例", fg="blue") self.imageShow.place(x=240, y=80, width=350, height=380) taskId = taskInfo.get('EarnDeatile').get('id') imageList = self.imageInfo.get(taskId) IMG = [] if imageList: for image in imageList: if image[0]: self.pil_image = Image.open(image[0]) self.pil_image = self.pil_image.resize((320, 350), Image.ANTIALIAS) IMG.append(self.pil_image) self.image = mtk.Label(self.imageShow) if IMG: self.counter = 0 self.imgNow = ImageTk.PhotoImage(IMG[self.counter]) self.image.configure(image=self.imgNow) self.image.place(x=2, y=2, width=322, height=352) self.image.bind( sequence="<MouseWheel>", func=lambda x: self.thread_it(self.changeImage, IMG)) self.image.bind(sequence="<Button-3>", func=lambda x: self.thread_it(self.saveImage, IMG)) else: self.image.configure(text="暂无图片", fg="red")
def add_neurons(self, neurons, plotter): c = 10 r = 1 for k in neurons: l = tK.Label(self.window, text=k, fg='black', bg='whitesmoke', bd=1, relief=tK.SOLID, width=8, font=('Helvetica', 12)) l.grid( column=c, row=r, padx=1, pady=2, ) l.bind("<Button-1>", partial(plotter, key=k)) self.neurons[k] = l if r is 25: c += 1 r = 1 else: r += 1
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 create_plugin_control(master, plugin_name, row_num, status_label): tk.Label(master, text=plugin_name, font='Helvetica 14 bold').grid(row=row_num, column=0, ipadx=20, ipady=20) tk.Button(master, text="Start", command=lambda: switch_plugin(plugin_name, 1)).grid(row=row_num, column=1) tk.Button(master, text="Stop", command=lambda: switch_plugin(plugin_name, 0)).grid(row=row_num, column=2) l = tk.Label(master, text="") l.grid(row=row_num, column=3, ipadx=10) l.config(bg='orange') status_label[row_num] = l
def makeView(self, master): frame = mtk.Frame(master, **self.configArgs) frame.pack(side=mtk.TOP, fill=mtk.X, padx=5, pady=5) l = mtk.Label(frame, text=self.label, anchor='w', **self.configArgs) l.pack(side=mtk.LEFT) self.cbx = Checkbox("", self.label, actionCallback=self.onClick, selectColor=self.selectColor) self.cbx.config(**self.configArgs) tk = self.cbx.makeView(frame) tk.pack(side=mtk.RIGHT) return frame
def makeView(self, master): frame = mtk.Frame(master, **self.configArgs) frame.pack(side=mtk.TOP, fill=mtk.X, padx=5, pady=5) l = mtk.Label(frame, width=15, text=self.label, anchor='w', **self.configArgs) l.pack(side=mtk.LEFT) self.button = ActionButton("", self.label, actionCallback=self.onClick, **self.args) self.button.config(**self.configArgs) buttonTk = self.button.makeView(frame) buttonTk.pack(side=mtk.RIGHT) return frame
def deviceinfo(): """ Gets the device info from the current selected device :return: Creates a new window for the device info """ serial = devices[current_device].serial global server conn = httplib.HTTPConnection(server.strip() + ":80") conn.request("GET", "/device_info/" + serial) r1 = conn.getresponse() data = r1.read() data = data[1:-1] toplevel = tk.Toplevel() label1 = tk.Label(toplevel, text="Device info for serial: " + serial, height=0, width=100) label1.pack() label2 = tk.Label(toplevel, text=data, height=0, width=100) label2.pack()
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 __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 __creatUI(self): self.box = mtk.LabelFrame(self.root) self.box.place(x=20, y=20, width=340, height=400) self.user_name = mtk.Label(self.box, text="账 号:") self.user_name.place(x=20, y=20, width=60, height=25) self.user_name_text = mtk.Entry(self.box) self.user_name_text.place(x=80, y=20, width=100, height=25) self.pass_word = mtk.Label(self.box, text="密 码:") self.pass_word.place(x=20, y=70, width=60, height=25) self.password_text = mtk.Entry(self.box) self.password_text.place(x=80, y=70, width=100, height=25) self.verify_code = mtk.Label(self.box, text="验证码:") self.verify_code.place(x=20, y=120, width=60, height=25) self.verify_code_text = mtk.Entry(self.box) self.verify_code_text.place(x=80, y=120, width=100, height=25) self.exam_name = mtk.Label(self.box, text="考试名称:") self.exam_name.place(x=20, y=170, width=60, height=25) self.exam_name_text = mtk.Entry(self.box) self.exam_name_text.place(x=80, y=170, width=100, height=25) self.loadbtn = mtk.Button(self.box, text="加载题型", command=lambda: self.thread_it(self.__loadExcel)) self.loadbtn.place(x=210, y=20, width=100, height=50) self.startbtn = mtk.Button(self.box, text="开始", command=lambda: self.thread_it(self.start)) self.startbtn.place(x=210, y=85, width=100, height=50) self.stopbtn = mtk.Button(self.box, text="退出", command=lambda: self.thread_it(self.stop)) self.stopbtn.place(x=210, y=150, width=100, height=50) self.logs = mtk.LabelFrame(self.box, text="信息", fg="blue") self.logs.place(x=20, y=210, width=300, height=170) self.logtext = scrolledtext.ScrolledText(self.logs, fg="green") self.logtext.place(x=20, y=10, width=270, height=130)
def agregar(self, imagen, x=0, y=0, width=0, height=0): #print(imagen) load = Image.open(imagen) if width > 0 and height > 0: load = load.resize((width, height), Image.ANTIALIAS) render = ImageTk.PhotoImage(load) label = tk.Label(self.master, image=render) label.image = render label.place(x=x, y=y) self.imgLabel.append(label) self.img.append(imagen) return
def load_ui(tab_rfid): # Toggle On/Off button config.submitBtn = mtk.Button(tab_rfid, text="Enable RFID Reader", command=lambda: rfid_on(config.submitBtn), height=1, width=25) config.submitBtn.place(x=0 + BORDER, y=400 + BORDER) # Clear textbox button clearBtn = mtk.Button(tab_rfid, text="Clear", command=clear, height=1, width=10) clearBtn.place(x=235 + BORDER, y=400 + BORDER) # Clear textbox button resetBtn = mtk.Button(tab_rfid, text="Reset", command=reset, height=1, width=10) resetBtn.place(x=350 + BORDER, y=400 + BORDER) # Label resultLabel = mtk.Label(tab_rfid, text="Output", background='black', foreground='white', width=78, height=1) resultLabel.place(x=0 + BORDER, y=0 + BORDER) # Scrolling textbox config.resultScrolledText = st.ScrolledText(tab_rfid, background='black', foreground='white', width=78, height=23) config.resultScrolledText.place(x=0 + BORDER, y=20 + BORDER)
def createPage(self): self.infoBox = mtk.LabelFrame(self.root, text="搜索框", fg="blue") self.infoBox.place(x=20, y=20, width=540, height=100) self.kw = mtk.Label(self.infoBox, text="关键词:") self.kw.place(x=20, y=20, width=50, height=25) self.kwText = mtk.Entry(self.infoBox) self.kwText.place(x=80, y=20, width=150, height=25) self.searchTime = mtk.Label(self.infoBox, text="搜索时间:") self.searchTime.place(x=280, y=20, width=60, height=25) self.stText = ttk.Combobox(self.infoBox) self.stText.place(x=350, y=20, width=100, height=25) self.stText["values"] = [ "7 Days", "14 Days", "30 Days", "45 Days", "60 Days", "90 Days", "1 Year" ] self.log = mtk.LabelFrame(self.root, text="log日志", fg="blue") self.log.place(x=20, y=140, width=300, height=350) self.logtext = scrolledtext.ScrolledText(self.log, fg="green") self.logtext.place(x=20, y=15, width=270, height=300) self.status = mtk.LabelFrame(self.root, text="当前进度", fg="blue") self.status.place(x=340, y=140, width=220, height=150) self.indexnow = mtk.Label(self.status, text="当前条数:") self.indexnow.place(x=20, y=20, width=60, height=25) self.indexnowText = mtk.Label(self.status, text="0 条") self.indexnowText.place(x=90, y=20, width=50, height=25) self.indexTotals = mtk.Label(self.status, text="总条数:") self.indexTotals.place(x=20, y=65, width=60, height=25) self.indexTotalsText = mtk.Label(self.status, text="0 条") self.indexTotalsText.place(x=90, y=65, width=50, height=25) self.btnBox = mtk.LabelFrame(self.root) self.btnBox.place(x=340, y=320, width=220, height=170) self.startbtn = mtk.Button(self.btnBox, text="开始", command=lambda: self.thread_it(self.start)) self.startbtn.place(x=40, y=20, width=120, height=40) self.loadoutbtn = mtk.Button( self.btnBox, text="导出", command=lambda: self.thread_it(self.export)) self.loadoutbtn.place(x=40, y=100, width=120, height=40)
def createwindow(root): """ Creates the gui window with all of its properties including, the menus, the scrollbar, the entrybox, and the display window :param root: The mainframe of the window """ global lb global textbox # Menus dropDown = tk.Menu(root) root.config(menu=dropDown) actions = tk.Menu(dropDown) dropDown.add_cascade(label="Actions", menu=actions) actions.add_command(label='Device Info', command=deviceinfo) actions.add_command(label='Clear Devices', command=cleardevices) actions.add_command(label='Clear', command=clearall) actions.add_command(label='Clear log', command=clearlog) actions.add_command(label='Help', command=helpaction) actions.add_command(label='Geolocation', command=geolocation) # actions.add_command(label='Quit', command=root.destroy()) lb = tk.Listbox(root, selectmode=tk.SINGLE) collecteddevices() lb.pack(side=tk.LEFT, fill=tk.Y) lb.bind('<ButtonRelease-1>', getlist) # Entrybox entry_cmd = tk.Entry(root, width=100) entry_cmd.pack(side=tk.BOTTOM) label_cmd = tk.Label(root, text="Command:") label_cmd.pack(side=tk.BOTTOM) entry_cmd.delete(0, tk.END) root.bind("<Return>", lambda x: changeinfo(entry_cmd.get(), entry_cmd)) # Scrollbar scroll = tk.Scrollbar(root) textbox = tk.Text(root, height=40, width=125) scroll.pack(side=tk.RIGHT, fill=tk.Y) textbox.pack(side=tk.TOP, fill=tk.Y) scroll.config(command=textbox.yview) textbox.config(yscrollcommand=scroll.set)
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)
def createPage(self): self.baseInfo = mtk.LabelFrame(self.root, text="当前用户", fg="blue") self.baseInfo.place(x=30, y=50, width=250, height=150) self.userName = mtk.Label(self.baseInfo, text="姓 名:") self.userName.place(x=20, y=10, width=80, height=25) self.userNameText = mtk.Entry(self.baseInfo) self.userNameText.place(x=110, y=10, width=100, height=25) self.userNameText.insert(0, self.NAME) self.userNameText.bind(sequence="<Return>", func=lambda x: self.thread_it(self.updateName)) self.taskName = mtk.Label(self.baseInfo, text="预约业务:") self.taskName.place(x=20, y=45, width=80, height=25) self.taskNameText = mtk.Label(self.baseInfo, text="人才引进落户申请") self.taskNameText.place(x=110, y=45, width=100, height=25) self.seetings = mtk.LabelFrame(self.root, text="设 置", fg="blue") self.seetings.place(x=320, y=50, width=250, height=150) self.taskDate = mtk.Label(self.seetings, text="预约日期:") self.taskDate.place(x=10, y=10, width=80, height=25) self.taskDateText = mtk.Entry(self.seetings) self.taskDateText.place(x=100, y=10, width=100, height=25) self.taskDateText.bind(sequence="<Double-Button-1>", func=lambda x: self.thread_it(self.getDate)) self.timeChoose = mtk.Label(self.seetings, text="预约时间:") self.timeChoose.place(x=10, y=50, width=80, height=25) self.timeChooseText = ttk.Combobox(self.seetings) self.timeChooseText.place(x=100, y=50, width=100, height=25) self.timeChooseText["values"] = ["09:00-12:00", "13:00-70:00"] self.taskSleep = mtk.Label(self.seetings, text="延时设置:") self.taskSleep.place(x=10, y=90, width=80, height=25) self.taskSleepText = mtk.Entry(self.seetings) self.taskSleepText.place(x=100, y=90, width=100, height=25) self.startBtn = mtk.Button( self.root, text="预约", command=lambda: self.thread_it(self.startTask)) self.startBtn.place(x=470, y=440, width=100, height=30) self.stopBtn = mtk.Button(self.root, text="暂停", command=lambda: self.thread_it(self.stop)) self.stopBtn.place(x=470, y=490, width=100, height=30) self.timeNow = mtk.LabelFrame(self.root, text="当前时间:", fg="blue") self.timeNow.place(x=450, y=270, width=150, height=120) self.timeNowText = mtk.Label(self.timeNow, fg="green") self.timeNowText.place(x=20, y=20, width=110, height=60) self.timeNowText["text"] = datetime.now().strftime( '%Y-%m-%d \n\n %H:%M:%S') self.logInfo = mtk.LabelFrame(self.root, text="日志信息", fg="blue") self.logInfo.place(x=30, y=230, width=400, height=350) self.logTxt = scrolledtext.ScrolledText(self.logInfo, fg="green") self.logTxt.place(x=20, y=15, width=360, height=290)
countdownms = 0 notdetectedcount = 0 running = True # Get images the cut will be compared to matchimage = cv2.imread("bomb.jpg", 0) histogram1 = cv2.calcHist([matchimage], [0], None, [256], [0, 256]) # compare image # Initialize tkinter window root = tk.Tk() root.title("Bombtimer") root.minsize(300, 270) # Display images and labels panellabel = tk.Label(root, text="Unprocessed") panel = tk.Label(root) panellabel.pack() panel.pack() panel2label = tk.Label(root, text="Masked") panel2 = tk.Label(root) panel2label.pack() panel2.pack() panel3label = tk.Label(root, text="Processed") panel3 = tk.Label(root) panel3label.pack() panel3.pack() seperatorlabel = tk.Label(
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) confirm = tk.Button(top, text="Confirm", command=receive_values_from_gui) # confirm.grid(row=2, 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)