• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tkinter.Button类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tkinter.Button的典型用法代码示例。如果您正苦于以下问题:Python Button类的具体用法?Python Button怎么用?Python Button使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Button类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: CircleBuilderPopup

class CircleBuilderPopup(BuilderPopup):
    """
    Class that launches a popup and collects user data to pass data back to the main window
    to build a circle.
    """
    def __init__(self, master):
        """
        Establish the GUI of this popup
        """
        BuilderPopup.__init__(self, master)
        self.data = (0, 0)
        self.radius = Label(self.top, text="Radius")
        self.radius_entry = Entry(self.top, width=self.width, bd=self.bd)
        self.center = Label(self.top, text="Center")
        self.center_entry = Entry(self.top, width=self.width, bd=self.bd)
        self.build_circle_submit = Button(self.top, text="Build!", command=self.cleanup)
        self.top.bind("<Return>", self.cleanup)
        self.radius.grid(row=0, column=0)
        self.radius_entry.grid(row=0, column=1)
        self.center.grid(row=1, column=0)
        self.center_entry.grid(row=1, column=1)
        self.build_circle_submit.grid(row=2, column=0, columnspan=2)
        self.top_left = 0
        self.bottom_right = 0
        self.radius_entry.focus()

    def cleanup(self, entry=None):
        """
        Collect the data from the user and package it into object variables, then close.
        """
        center = complex(0, 0)
        if self.center_entry.get():
            center = complex(allow_constants(self.center_entry.get()))
        self.data = (float(allow_constants(self.radius_entry.get())), center)
        self.top.destroy()
开发者ID:SamuelDoud,项目名称:complex-homotopy,代码行数:35,代码来源:BuilderWindows.py


示例2: Demo

class Demo(Frame):
    def __init__(self, parent, *args, **kw):
        Frame.__init__(self, parent, *args,**kw)
        self.e=Entry(self, text='Message')
        self.e.delete(0,'end')
        self.e.pack()
        self.makebuttons()        
        self.pack(expand='true',fill='x')

    def makebuttons(self):
        self.b1=Button(self, text="restart",bg="blue",fg='white',command= self.restart )
        self.b1.pack(side='right',fill='both' )
        self.b2=Button(self,text='quit',bg='green',fg='white',command=self.quit)
        self.b2.pack(side='left',fill='both')
        self.lastTime=""
        self.start_timer()
        
    def start_timer(self):
        pass

    def destroy(self):
        self.pack_forget()
    

    def restart(self):
        self.destroy()
        D=Demo(root,bg='purple')
        print ("killed")
        D.__init__(self,root)
        pass
    
    def quit(self):
        root.destroy()
开发者ID:jbpeters,项目名称:Time-keeper,代码行数:33,代码来源:tkmin.py


示例3: create_toolbar

 def create_toolbar(self):
     self.toolbar = Frame(self.parent)
     self.btn_new = Button(self.toolbar, text='New', command=self.new_file)
     self.btn_new.grid(row=0, column=0)
     self.btn_open = Button(self.toolbar, text='Open', command=self.open_file)
     self.btn_open.grid(row=0, column=1)
     self.toolbar.pack(fill='both')
开发者ID:felixlu,项目名称:pyBooguNote,代码行数:7,代码来源:pyBooguNote.py


示例4: __init__

    def __init__(self, client):
        # Basic setup
        super(Preferences, self).__init__()
        self.client = client

        # Setup the variables used
        self.echo_input = BooleanVar()
        self.echo_input.set(self.client.config['UI'].getboolean('echo_input'))
        self.echo_input.trace("w", self.echo_handler)
        self.logging = BooleanVar()
        self.logging.set(self.client.config['logging'].getboolean('log_session'))
        self.logging.trace('w', self.logging_handler)
        self.log_dir = self.client.config['logging']['log_directory']

        # Build the actual window and widgets
        prefs = Toplevel(self)
        prefs.wm_title("Preferences")
        echo_input_label = Label(prefs, text="Echo Input:")
        logging_label = Label(prefs, text='Log to file:')
        echo_checkbox = Checkbutton(prefs, variable=self.echo_input)
        logging_checkbox = Checkbutton(prefs, variable=self.logging)
        logging_button_text = 'Choose file...' if self.log_dir == "" else self.log_dir
        logging_button = Button(prefs, text=logging_button_text, command=self.logging_pick_location)

        # Pack 'em in.
        echo_input_label.grid(row=0, column=0)
        echo_checkbox.grid(row=0, column=1)
        logging_label.grid(row=1, column=0)
        logging_checkbox.grid(row=1, column=1)
        logging_button.grid(row=1, column=2)
开发者ID:Errorprone85,项目名称:TEC-Client,代码行数:30,代码来源:preferences.py


示例5: __init__

    def __init__(self, master=None):
        # Avoiding to send it continuously.
        self.lock = False

        Frame.__init__(self, master)
        self.grid()
        self.master = master
        # Setting for ComboBox.
        self.url_lang_combobox_str = StringVar()
        self.url_lang_combobox_list = lang_list
        # UI components.
        self.receiver_email_text = Label(self, text="Receiver:")
        self.receiver_email_field = Entry(self, width=50)
        self.subject_text = Label(self, text='Subject:')
        self.subject_field = Entry(self, width=50)
        self.receiver_name_text = Label(self, text='Name:')
        self.receiver_name_field = Entry(self, width=50)
        self.url_lang_text = Label(self, text='Link lang:')
        self.url_lang_combobox = Combobox(self, textvariable=self.url_lang_combobox_str, values=self.url_lang_combobox_list, state='readonly')
        self.send_progressbar = Progressbar(self, orient='horizontal', length=500, mode='determinate', maximum=300)
        self.send_button = Button(self, text='Send', command=self._send_mail)
        self.quit_button = Button(self, text='Exit', command=self.__exit)
        self.log_msg_text = ScrolledText(self)
        # Attachment.
        self.mail_attachment_list = attachment_list[:]
        self.url_lang_link_title = None
        self.url_lang_link = copy.deepcopy(content_link)
        # Mailer
        self._mailer = None

        # Let Mailer can control components.
        Mailer.window_content = self

        self.__create_widgets()
开发者ID:pokk,项目名称:Mailer,代码行数:34,代码来源:auto_mailer.py


示例6: Application

class   Application(Frame): 
    def __init__(self,  master=None):
        Frame.__init__(self, master)    
        self.grid(sticky=N+S+E+W)   
        self.mainframe()

    def mainframe(self):                
        self.data = Listbox(self, bg='red')
        self.scrollbar = Scrollbar(self.data, orient=VERTICAL)
        self.data.config(yscrollcommand=self.scrollbar.set)
        self.scrollbar.config(command=self.data.yview)

        for i in range(1000):
            self.data.insert(END, str(i))

        self.run = Button(self, text="run")
        self.stop = Button(self, text="stop")
    
        self.data.grid(row=0, column=0, rowspan=4,
                       columnspan=2, sticky=N+E+S+W)
        self.data.columnconfigure(0, weight=1)
    
        self.run.grid(row=4,column=0,sticky=EW)
        self.stop.grid(row=4,column=1,sticky=EW)
    
        self.scrollbar.grid(column=2, sticky=N+S)
开发者ID:shawncx,项目名称:LogParser,代码行数:26,代码来源:scrolltest.py


示例7: make_button

 def make_button(self, label, command, isdef=0):
     "Return command button gridded in command frame."
     b = Button(self.buttonframe, text=label, command=command, default=isdef and "active" or "normal")
     cols, rows = self.buttonframe.grid_size()
     b.grid(pady=1, row=rows, column=0, sticky="ew")
     self.buttonframe.grid(rowspan=rows + 1)
     return b
开发者ID:alexandremetgy,项目名称:MrPython,代码行数:7,代码来源:SearchDialogBase.py


示例8: __init__

 def __init__(self, master, line_collection):
     try:
         self.width_of_entry = len(line_collection[0])
     except IndexError:
         self.width_of_entry = 0
     self.top = Toplevel(master)
     self.current_lines_listbox = Listbox(self.top)
     self.removed_lines_listbox = Listbox(self.top)
     self.submit = Button(self.top, text = "Ok", command=self.submit)
     self.remove_button = Button(self.top, text = "Remove", command=self.remove_line)
     self.cancel = Button(self.top, text = "Cancel", command=self.top.destroy)
     self.top.bind("<Return>", func=self.submit)
     self.current_lines = line_collection
     self.removed_lines = []
     self.ids_internal = []
     self.ids = []
     for index, line in enumerate(self.current_lines):
         #removes the point data and converts the rest to strings
         id = line[1]
         if id not in self.ids_internal:
             self.ids_internal.append(id)
             self.ids.append(id)
             line = [str(element) for element in line[1:]]
             
             #put into the list
             self.current_lines_listbox.insert(index, " ".join(line))
     self.current_lines_listbox.grid(row=0, column=0, columnspan=3)
     self.submit.grid(row=1, column=1)
     self.cancel.grid(row=1, column=2)
     self.remove_button.grid(row=1, column=0)
开发者ID:SamuelDoud,项目名称:complex-homotopy,代码行数:30,代码来源:ShapesMenu.py


示例9: __init__

    def __init__(self, master):
        self.master = master
        master.title("Calculator")

        self.total = 0
        self.entered_number = 0

        self.total_label_text = IntVar()
        self.total_label_text.set(self.total)
        self.total_label = Label(master, textvariable=self.total_label_text)

        self.label = Label(master, text="Total:")

        vcmd = master.register(self.validate)  # we have to wrap the command
        self.entry = Entry(master, validate="key", validatecommand=(vcmd, "%P"))

        self.add_button = Button(master, text="+", command=lambda: self.update("add"))
        self.subtract_button = Button(master, text="-", command=lambda: self.update("subtract"))
        self.multiply_button = Button(master, text="*", command=lambda: self.update("multiply"))
        # self.divide_button = Button(master, text="/", command=lambda: self.update("divide"))
        self.reset_button = Button(master, text="Reset", command=lambda: self.update("reset"))

        # LAYOUT
        self.label.grid(row=0, column=0, sticky=W)
        self.total_label.grid(row=0, column=1, columnspan=2, sticky=E)
        self.entry.grid(row=1, column=0, columnspan=5, sticky=W + E)
        self.add_button.grid(row=2, column=0)
        self.subtract_button.grid(row=2, column=1)
        self.multiply_button.grid(row=2, column=2)
        # self.divide_button.grid(row=2, column=3)
        self.reset_button.grid(row=2, column=4, sticky=W + E)
开发者ID:anwittin,项目名称:Python,代码行数:31,代码来源:calc.py


示例10: __init__

 def __init__(self, method=None, master=None):
     self.method = method
     self.picframe = Frame.__init__(self, master)
     self.master.title("Robobackup")
     self.image = PhotoImage()
     self.image["file"] = os.path.join(os.path.dirname(\
         os.path.relpath(__file__)), "resources", "ASK.png")
     self.piclabel = Label(self.picframe, image=self.image)
     self.piclabel.grid(row=0, column=0, columnspan=4, rowspan=6)
     self.clocklabel = Label(self.picframe, text=_("Elapsed time:"))
     self.clocklabel.grid(row=0, column=4, sticky="NSEW")
     self.clock = Label(self.picframe, text="")
     self.clock.grid(row=1, column=4, sticky="NSEW")
     self.start = Button(self.picframe, text=_("Start Backup"), command=self.__clk)
     self.start.grid(row=3, column=4, sticky="NSEW")
     self.errorlabel = Label(self.picframe)
     self.errorlabel.grid(row=4, column=4, sticky="NSEW")
     self.close = Button(self.picframe, text=_("Close"), command=self.__cls)
     self.close.grid(row=5, column=4, sticky="NSEW")
     self.loglabel = Label(self.picframe, text=_("Log:"), justify="left")
     self.loglabel.grid(row=6, column=0, columnspan=5, sticky="NSEW")
     self.text = Text(self.picframe)
     self.text.grid(row=7, column=0, rowspan=6, columnspan=5, sticky="NSEW")
     self.timeout = False
     self.starttime = -1
开发者ID:peastone,项目名称:robobackup,代码行数:25,代码来源:tkintergui.py


示例11: create_monitor

 def create_monitor(self):
     self.monitor_frame = LabelFrame(self, text="Monitor and Transport")
     this_cycle = Scale(self.monitor_frame, label='cycle_pos', orient=HORIZONTAL,
                        from_=1, to=16, resolution=1)
     this_cycle.disable, this_cycle.enable = (None, None)
     this_cycle.ref = 'cycle_pos'
     this_cycle.grid(column=0, row=0, sticky=E + W)
     self.updateButton = Button(self.monitor_frame,
                                text='Reload all Settings',
                                command=self.request_update)
     self.updateButton.grid(row=1, sticky=E + W)
     self.ForceCaesuraButton = Button(self.monitor_frame,
                                      text='Force Caesura',
                                      command=self.force_caesura)
     self.ForceCaesuraButton.grid(row=2, sticky=E + W)
     self.saveBehaviourButton = Button(self.monitor_frame,
                                       text='Save current behaviour',
                                       command=self.request_saving_behaviour)
     self.saveBehaviourButton.grid(row=3, sticky=E + W)
     self.saveBehaviourNameEntry = Entry(self.monitor_frame)
     self.saveBehaviourNameEntry.grid(row=4, sticky=E + W)
     self.saveBehaviourNameEntry.bind('<KeyRelease>', self.request_saving_behaviour)
     self.selected_behaviour = StringVar()
     self.selected_behaviour.trace('w', self.new_behaviour_chosen)
     self.savedBehavioursMenu = OptionMenu(self.monitor_frame,
                                           self.selected_behaviour, None,)
     self.savedBehavioursMenu.grid(row=5, sticky=E + W)
     self.monitor_frame.grid(column=0, row=10, sticky=E + W)
开发者ID:kr1,项目名称:roqba,代码行数:28,代码来源:main.py


示例12: Example

class Example(Frame):

	def __init__(self, parent):
		Frame.__init__(self, parent)

		self.parent = parent
		self.initUI()

	def initUI(self):

		self.parent.title("test")
		self.pack(fill=BOTH, expand=1)

		self.cal = Button(self)
		self.cal["text"] = "Calculate"
		self.cal["command"] = self.cal_frequency
		self.cal.pack(fill=BOTH, expand=1)

	def cal_frequency(self):
		# use the dialog to find the route of the file
		file_path = filedialog.askopenfilename()
		frequency = [ 0 for i in range(26)]
		f = open(file_path, 'r')
		article = f.read()
		for i in article:
			seq = alpha_to_num(i)
			if seq != -1:
				frequency[seq] += 1
		print (frequency)
开发者ID:floydxiu,项目名称:Crypto_learning,代码行数:29,代码来源:letter_analysis.py


示例13: __init__

    def __init__(self, parent):
       
        # super(createSets,self).__init__(parent)
        Frame.__init__(self, parent)
        self.parent = parent
        self.grid(row=0, column=0)

        self.parentWindow = 0

        self.listBox = Listbox(self, selectmode=EXTENDED)
        self.listBox.grid(row=1, column=1)
        for item in ["one", "two", "three", "four"]:
            self.listBox.insert(END, item)
        
        self.buttonDel = Button(self,
                                text="delite selected class",
                                command=self.del_selected)  # lambda ld=self.listBox:ld.delete(ANCHOR))
        self.buttonDel.grid(row=0, column=0)
            
        self.entry = Entry(self, state=NORMAL)
        # self.entry.focus_set()
        self.entry.insert(0, "default")
        self.entry.grid(row=1, column=0)
        
        self.buttonInsert = Button(self, text="add new class",
                                   command=self.add)
        self.buttonInsert.grid(row=0, column=1)
        
        self.buttonDone = Button(self, text="done", command=self.done)
        self.buttonDone.grid(row=2, column=0)
开发者ID:valdecar,项目名称:faceRepresentWithHoG,代码行数:30,代码来源:gui.py


示例14: InfoFrame

class InfoFrame(Frame):
    def __init__(self,master=None, thread=None):
        Frame.__init__(self, master)
        self.controlThread=thread
        
        self.stringVar=StringVar()
        
        self.grid()
        self.createWidgets()
        
    def createWidgets(self):
        self.inputText=Label(self)
        if self.inputText != None:
            self.inputText['textvariable']=self.stringVar
            self.inputText["width"] = 50
            self.inputText.grid(row=0, column=0, columnspan=6)
        else:
            pass
        
        
        self.cancelBtn = Button(self, command=self.clickCancelBtn)   # need to implement
        if self.cancelBtn !=None:
            self.cancelBtn["text"] = "Cancel"
            self.cancelBtn.grid(row=0, column=6)
        else:
            pass
        
    def clickCancelBtn(self):
        print("close the InfoDialog")
        self.controlThread.setStop()
            
    def updateInfo(self, str):
        self.stringVar.set(str)
开发者ID:fscnick,项目名称:RapidgatorDownloader,代码行数:33,代码来源:DialogThread.py


示例15: __init__

class MessageTester:
    def __init__(self, root):
        root.title("Message tester")
        Label(root, text="Enter message event below", bg="light green").pack()
        self.event_field = ScrolledText(root, width=180, height=10)
        self.event_field.pack()

        Label(root, text="Enter test case below", bg="light green").pack()
        self.test_case_field = ScrolledText(root, width=180, height=20)
        self.test_case_field.pack()

        Label(root, text="Test result:", bg="light green").pack()

        self.result_field = ScrolledText(root, width=180, height=10)
        self.result_field.pack()
        self.result_field.config(state=DISABLED)
        self.button = Button(root, text="Evaluate", fg="red",
                             command=self._clicked)
        self.button.pack()

        self.event_field.delete('1.0', END)
        self.event_field.insert('insert', EXAMPLE_EVENT)
        self.test_case_field.delete('1.0', END)
        self.test_case_field.insert('insert', EXAMPLE_TEST_CASE)

    def _clicked(self):
        event = self.event_field.get('1.0', END)
        test_case = self.test_case_field.get('1.0', END)

        evaluation = skill_tester.EvaluationRule(ast.literal_eval(test_case))
        evaluation.evaluate(ast.literal_eval(event))
        self.result_field.config(state=NORMAL)
        self.result_field.delete('1.0', END)
        self.result_field.insert('insert', evaluation.rule)
        self.result_field.config(state=DISABLED)
开发者ID:Dark5ide,项目名称:mycroft-core,代码行数:35,代码来源:message_tester.py


示例16: __init__

class MyFirstGUI:
    LABEL_TEXT = [
        "This is our first GUI!",
        "Actually, this is our second GUI.",
        "We made it more interesting...",
        "...by making this label interactive.",
        "Go on, click on it again.",
    ]
    def __init__(self, master):
        self.master = master
        master.title("A simple GUI")

        self.label_index = 0
        self.label_text = StringVar()
        self.label_text.set(self.LABEL_TEXT[self.label_index])
        self.label = Label(master, textvariable=self.label_text)
        self.label.bind("<Button-1>", self.cycle_label_text)
        self.label.pack()

        self.greet_button = Button(master, text="Greet", command=self.greet)
        self.greet_button.pack()

        self.close_button = Button(master, text="Close", command=master.quit)
        self.close_button.pack()

    def greet(self):
        print("Greetings!")

    def cycle_label_text(self, event):
        self.label_index += 1
        self.label_index %= len(self.LABEL_TEXT) # wrap around
        self.label_text.set(self.LABEL_TEXT[self.label_index])
开发者ID:gshkr123,项目名称:Python_Task,代码行数:32,代码来源:GUI-Lables.py


示例17: initUI

    def initUI(self):
        self.parent.title('PyZilla')
        self.padding = 5

        self.pack(fill=BOTH, expand=1)

        # Create a menubar
        mnuMenu = Menu(self.parent)
        self.parent.config(menu=mnuMenu)

        # Create menubar
        mnuFileMenu = Menu(mnuMenu)

        # Add File menu items
        mnuFileMenu.add_command(label='Open', command=self.onBtnOpenFile)
        mnuFileMenu.add_command(label='Exit', command=self.quit)

        # Add File menu items to File menu
        mnuMenu.add_cascade(label='File', menu=mnuFileMenu)

        # Create frame for all the widgets
        frame = Frame(self)
        frame.pack(anchor=N, fill=BOTH)

        # Create file open dialog
        btnOpenFile = Button(frame, text="Load file", command=self.onBtnOpenFile)
        btnOpenFile.pack(side=RIGHT, pady=self.padding)

        # Create filename label
        self.lblFilename = Label(frame, text='No filename chosen...')
        self.lblFilename.pack(side=LEFT, pady=self.padding, padx=self.padding)

        # Create the text widget for the results
        self.txtResults = Text(self)
        self.txtResults.pack(fill=BOTH, expand=1, pady=self.padding, padx=self.padding)
开发者ID:claudemuller,项目名称:pyzilla,代码行数:35,代码来源:pyzilla.py


示例18: add_pairs

    def add_pairs( self, parent ) :
        if not self.pairs :
            self.pairs = LabelFrame(parent, text='Pairs')
            self.pairs_text = Text( self.pairs,
                             width=50,
                             height=8,
                             #bg=projectBgColor,
                             #fg=projectFgColor,
                             font=("nimbus mono bold","11")
                            )

            self.pairs_save_button = Button(self.pairs, 
                                            text="Save", 
                                            command = self.writepair )
            
            self.pairs_load_button = Button(self.pairs,
                                            text="Load",
                                            command = self.readpair )
            
            #self.pairs_load_button.pack( side=BOTTOM, padx=5, pady=5 )
            #self.pairs_save_button.pack( side=BOTTOM, padx=5, pady=5 )

            self.pairs_load_button.grid( row=5, column=5, padx=10, pady=5 )
            self.pairs_save_button.grid( row=5, column=6, padx=10, pady=5 )
            self.pairs_text.grid( row=1,  rowspan=3, 
                                 column=1,  columnspan=7,
                                 padx=5, pady=5 )

        self.pairs.grid(row=7,column=0, columnspan=6, sticky=W, padx=20, pady=10 )
开发者ID:CCBR,项目名称:Pipeliner,代码行数:29,代码来源:exomeseq.py


示例19: _reset_controls

    def _reset_controls(self):
        """ Resets the controls on the form. """
        image = ImageTk.PhotoImage(file="bg.png")
        
        # Initialize controls
        self.lbl_bg = Label(self, image=image)
        self.lbl_dir = Label(self, bg="white", fg="#668FA7", font=("Courier", 14))
        self.lbl_anon = Label(self, bg="white", fg="#668FA7", font=("Courier", 14))
        self.lbl_id = Label(self, bg="white", fg="#668FA7", font=("Courier", 14))
        self.btn_dir_select = Button(self, text="Select data folder", command=self._btn_dir_press)
        self.btn_id = Button(self, text="Identify data", command=self._btn_id_press)
        self.btn_anon = Button(self, text="Anonymize data", command=self._btn_anon_press)
        self.tb_study = Entry(self, bg="#668FA7", fg="white")
        self.prg_id = Progressbar(self, orient="horizontal", length=200, mode="determinate")
        self.prg_anon = Progressbar(self, orient="horizontal", length=200, mode="determinate")

        # Place controls
        self.lbl_bg.place(x=0, y=0, relwidth=1, relheight=1)
        self.lbl_anon.place(x=400, y=400)
        self.lbl_id.place(x=400, y=325)
        self.btn_dir_select.place(x=250, y=250)
        self.btn_id.place(x=250, y=325)
        self.btn_anon.place(x=250, y=400)
        self.tb_study.place(x=250, y=175)
        self.prg_id.place(x=410, y=290)
        self.prg_anon.place(x=410, y=370)

        # Other formatting
        self.lbl_bg.image = image
        self.btn_id['state'] = "disabled"
        self.btn_anon['state'] = "disabled"
        self.prg_id['maximum'] = 100
        self.prg_anon['maximum'] = 100
开发者ID:Sciprios,项目名称:Anonymizer,代码行数:33,代码来源:views.py


示例20: test_gui

    def test_gui(self):
        """
        The GUI interactions by simulating user actions
        """
        tl = Toplevel()
        gui = ClassicGUI(tl)
        gui.colorPicker = DummyColorPicker(tl)
        controller = DrawController(gui)
        self.assertEquals(gui.ioButtons.__len__(), 5, "There should be 5 IO buttons")
        self.assertEquals(gui.commandButtons.__len__(), 4, "There should be 4 draw command buttons")

        gui.onChangeColor(gui.colorPickerButton)
        self.assertEquals(gui.colorPickerButton.cget('bg'), gui.colorPicker.getColor())

        dummyButton = Button()
        gui.onDrawCommandButtonClick(dummyButton, LineDrawCommand)
        self.assertEquals(dummyButton.cget('relief'), SUNKEN, "Selected button should have style SUNKEN")

        for btn in gui.commandButtons:
            self.assertEquals(btn.cget('relief'), FLAT, "Selected button should have style FLAT")

        self.assertEquals(type(controller.activeCommand), LineDrawCommand, "Active command should be LineDrawCommand")

        for cmd in controller.commands:
            controller.canvas.getDrawArea().delete(ALL)
            self.assertCommandOperations(controller, cmd)

        clearCmd = NewDrawCommand()
        gui.onIOCommandClick(dummyButton, clearCmd)
        self.assertEquals(gui.canvas.getDrawArea().find_all().__len__(), 0,
                          "The canvas should be cleared on NewDrawCommand")
开发者ID:tu-tran,项目名称:DrawingProjectPython,代码行数:31,代码来源:test.py



注:本文中的tkinter.Button类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tkinter.Canvas类代码示例发布时间:2022-05-27
下一篇:
Python tkinter.BooleanVar类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap