当前位置: 首页>>代码示例>>Python>>正文


Python tkinter.IntVar类代码示例

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


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

示例1: main

    def main(self):
        '''Function to run on game start'''
        self.mainMenu=Tk()
        self.mainMenu.geometry('200x300+200+200')
        self.mainMenu.title("Minesweeper")
        playButton=Button(self.mainMenu,text='Play',command=lambda:self.startPlay(None))

        self.height= IntVar()
        self.width= IntVar()
        self.minesAmount= IntVar()

        self.height.set(10)
        self.width.set(10)
        self.minesAmount.set(10)

        playButton.pack()
        
        xSlider=Scale(self.mainMenu,orient='horizontal',length=150,width=15,label='Height',sliderlength=20,from_=1,to=15,tickinterval=0,variable=self.height).pack()
        ySlider=Scale(self.mainMenu,orient='horizontal',length=150,width=15,label='Width',sliderlength=20,from_=1,to=15,tickinterval=0,variable=self.width).pack()      
        minesSlider=Scale(self.mainMenu,orient='horizontal',length=150,width=15,label='Mines',sliderlength=20,from_=0,to=15*15-1,tickinterval=0,variable=self.minesAmount).pack()
        
        aboutButton=Button(self.mainMenu,text='About',command=self.about)
        quitButton=Button(self.mainMenu,text='Quit',command=self.quitApp)

        
        
        aboutButton.pack()
        quitButton.pack()
开发者ID:kodmarcel,项目名称:Minesweeper,代码行数:28,代码来源:Main.py

示例2: DlgLogin

class DlgLogin(Dialog):
    def body(self, master, cfg={}):
        "place user dialog widgets"
        self.config = cfg
        self.config["OK button"] = False
        self.site = StringVar()
        self.site.set(cfg.get("site", ""))
        self.login = StringVar()
        self.login.set(cfg.get("user", ""))
        self.password = StringVar()
        self.password.set(str(cfg.get("password", "")))
        site = Entry(master, width=15, textvariable=self.site)
        site.grid(column=1, row=0, sticky="e")
        Label(master, text=_("Site:")).grid(column=0, row=0, sticky="w")
        loge = Entry(master, width=15, textvariable=self.login)
        loge.grid(column=1, row=1, sticky="e")
        Label(master, text=_("Username:")).grid(column=0, row=1, sticky="w")
        pase = Entry(master, width=15, textvariable=self.password, show="*")
        pase.grid(column=1, row=2, sticky="e")
        Label(master, text=_("Password:")).grid(column=0, row=2, sticky="w")
        self.to_remember = IntVar()
        self.to_remember.set(cfg.get("remember_passwd", 1))
        chk1 = Checkbutton(master, text="Remember",
                           variable=self.to_remember)
        chk1.grid(column=0, row=3, sticky="w", columnspan=2)
        self.resizable(width=0, height=0)
        return loge

    def apply(self):
        "On ok button pressed"
        self.config["remember_passwd"] = self.to_remember.get()
        self.config["site"] = self.site.get()
        self.config["user"] = self.login.get()
        self.config["password"].set_password(self.password.get())
        self.config["OK button"] = True
开发者ID:Lysovenko,项目名称:OTRS_US,代码行数:35,代码来源:dialogs.py

示例3: test_get

 def test_get(self):
     v = IntVar(self.root, 123, "name")
     self.assertEqual(123, v.get())
     self.root.globalsetvar("name", "345")
     self.assertEqual(345, v.get())
     self.root.globalsetvar("name", "876.5")
     self.assertEqual(876, v.get())
开发者ID:1st1,项目名称:cpython,代码行数:7,代码来源:test_variables.py

示例4: test_invalid_value

 def test_invalid_value(self):
     v = IntVar(self.root, name="name")
     self.root.globalsetvar("name", "value")
     with self.assertRaises(ValueError):
         v.get()
     self.root.globalsetvar("name", "345.0")
     with self.assertRaises(ValueError):
         v.get()
开发者ID:Cartmanfku,项目名称:cpython,代码行数:8,代码来源:test_variables.py

示例5: initialize_ui

  def initialize_ui(self):
    default_padding = {'padx': 10, 'pady' : 10}

    customer_frame = Frame(self)
    self.customer_id_label = Label(customer_frame, text = "Customer id:", style="BW.TLabel")
    self.customer_id_label.pack(default_padding, side = LEFT)

    self.customer_id_value = Label(customer_frame,style="BW.TLabel")
    self.customer_id_value["textvariable"] = self.controller.customer_id
    self.customer_id_value.pack(default_padding, side = LEFT)

    customer_frame.pack(expand = True, fill = "x")

    self.take_picture_frame = Frame(self, border = 10)
    
    self.picture_mode = IntVar()
    Radiobutton(self.take_picture_frame, text = "Light", variable = self.picture_mode, value = 1).pack(side = LEFT)
    Radiobutton(self.take_picture_frame, text = "Dark", variable = self.picture_mode, value = 2).pack(side = LEFT)
    
    self.button_take_picture = Button(self.take_picture_frame, text = "Take picture", command = self.take_picture)
    self.button_take_picture.pack(expand = True, fill = "x", side = BOTTOM)

    self.take_picture_frame.pack(expand = True)
    
    self.button_update = Button(self, text = "Update", command = self.controller.run_update_script)
    self.button_update.pack(expand = True, fill = "x")
开发者ID:khlumzeemee,项目名称:3dprinter,代码行数:26,代码来源:ApplicationMVC.py

示例6: NetworkPage

class NetworkPage(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)

        self.generalnavframe = ttk.Frame(self)
        self.generalnavframe.grid(row=0, column=0, sticky="nsew")

        self.generalpagebutt = tk.Button(self.generalnavframe, text="General", width=10, height=3, command=lambda: controller.show_frame(GeneralPage))
        self.generalpagebutt.grid(row=0, column=0)

        self.filesyspagebutt = tk.Button(self.generalnavframe, text="File System", width=10, height=3, command=lambda: controller.show_frame(FileSYSPage))
        self.filesyspagebutt.grid(row=0, column=1)

        self.serialpagebutt = tk.Button(self.generalnavframe, text="Serial", width=10, height=3, command=lambda: controller.show_frame(SerialPage))
        self.serialpagebutt.grid(row=0, column=2)

        self.networkpagebutt = tk.Button(self.generalnavframe, text="Network", width=10, height=3, bg='gray', command=lambda: controller.show_frame(NetworkPage))
        self.networkpagebutt.grid(row=0, column=3)

        self.generalcontrollsframe = ttk.Frame(self)  # secondary frame with page controlls
        self.generalcontrollsframe.grid(row=1, column=0, sticky="nsew")

        self.var = IntVar()
        self.var.set(2)

        self.dhcp = ttk.Radiobutton(self.generalcontrollsframe, text="Dhcp", variable=self.var, value=2)
        self.dhcp.grid(row=0, column=1)

        self.static = ttk.Radiobutton(self.generalcontrollsframe, text="Static", variable=self.var, value=1)
        self.static.grid(row=0, column=0)

        self.ipaddress = ttk.Label(self.generalcontrollsframe, text="Ip Address")
        self.ipaddress.grid(row=1, column=0)
        self.ipaddrv4 = ttk.Entry(self.generalcontrollsframe, width=16)
        self.ipaddrv4.grid(row=1, column=1)

        self.subnetlbl = ttk.Label(self.generalcontrollsframe, text="Subnet")
        self.subnetlbl.grid(row=2, column=0)
        self.subnet = ttk.Entry(self.generalcontrollsframe, width=16)
        self.subnet.grid(row=2, column=1)

        self.gatewaylbl = ttk.Label(self.generalcontrollsframe, text="Gateway")
        self.gatewaylbl.grid(row=3, column=0)
        self.gateway = ttk.Entry(self.generalcontrollsframe, width=16)
        self.gateway.grid(row=3, column=1)

        self.dns1lbl = ttk.Label(self.generalcontrollsframe, text="Dns1")
        self.dns1lbl.grid(row=4, column=0)
        self.dns1 = ttk.Entry(self.generalcontrollsframe, width=16)
        self.dns1.grid(row=4, column=1)

        self.dns2lbl = ttk.Label(self.generalcontrollsframe, text="Dns2")
        self.dns2lbl.grid(row=5, column=0)
        self.dns2 = ttk.Entry(self.generalcontrollsframe, width=16)
        self.dns2.grid(row=5, column=1)

        self.setnetwork = ttk.Button(self.generalcontrollsframe, text="Set", width=16)
        self.setnetwork.grid(row=7, column=0, columnspan=2)
开发者ID:techead1982,项目名称:Gbrl-Rpi-gcode-DCLaser-Sender,代码行数:58,代码来源:laserUI_beta2.py

示例7: Checkbox

class Checkbox(Checkbutton):
    def __init__(self, master, text, default=None, **args):
        self.var = IntVar()
        Checkbutton.__init__(self, master, text=text, variable=self.var, **args)
        if default is not None:
            self.var.set(default)

    def get(self):
        return self.var.get()
开发者ID:bbferka,项目名称:pracmln,代码行数:9,代码来源:widgets.py

示例8: FrameKSPObject

class FrameKSPObject(Frame):
    
    
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        frame = Frame(self)
        frame.pack()
        self.string_var0 = StringVar()
        self.string_var1 = StringVar()
        self.int_var = IntVar()
        self.entry0 = Entry(frame, textvariable=self.string_var0)
        self.entry0.pack(side='left')
        Entry(frame, textvariable=self.string_var1).pack(side='left')
        frame = Frame(self)
        frame.pack()
        Button(frame, width=8, text='Accept', command=self.accept).pack(side='left')
        Button(frame, width=8, text='Cancel', command=self.cancel).pack(side='left')
        Button(frame, width=8, text='Delete', command=self.delete).pack(side='left')
        
        
    def populate(self, kspobject):
        self._kspobject = kspobject
        self.string_var0.set(kspobject.name)
        self.string_var1.set(kspobject.value)
        self.int_var.set(kspobject.id_)
        
        
    def accept(self):
        name = self.string_var0.get()
        value = self.string_var1.get()
        id_ = self.int_var.get()
        self.master.master.update_kspobject(name, value, id_)
        self.master.destroy()
    
    
    def cancel(self):
        self.master.destroy()
    
    
    def delete(self):
        id_ = self.int_var.get()
        self.master.master.delete_kspobject(id_)
        self.master.destroy()
        
        
        
        
        
        
        
        
        
        
        
        
        
开发者ID:dan2082,项目名称:KSPData,代码行数:44,代码来源:frame_kspobject.py

示例9: __init__

class Calculator:
    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)

    def validate(self, new_text):
        if not new_text:  # the field is being cleared
            self.entered_number = 0
        return True

        try:
            self.entered_number = int(new_text)
            return True
        except ValueError:
            return False

    def update(self, method):
        if method == "add":
            self.total += self.entered_number
        elif method == "subtract":
            self.total -= self.entered_number
        elif method == "multiply":
            self.total *= self.entered_number
        elif method == "divide":
            self.total /= self.entered_number
        else:  # reset
            self.total = 0
        self.total_label_text.set(self.total)
        self.entry.delete(0, END)
开发者ID:anwittin,项目名称:Python,代码行数:57,代码来源:calc.py

示例10: DiceTab

class DiceTab(Frame):
    def __init__(self,master=None):
        Frame.__init__(self,master)
        #Sides of Dice
        labelSides=Label(self,text="Sides")
        labelSides.grid(row=0,column=0)
        self.sides=StringVar()
        self.sides.set(20)
        spinboxSides=Spinbox(self,from_=1,to=20,increment=1,width=4)
        spinboxSides.config(textvariable=self.sides, font="sans 24", justify="center")
        spinboxSides.grid(row=0,column=1)
        #Number of Dices
        labelNumber=Label(self,text="Number")
        labelNumber.grid(row=1,column=0)
        self.number=StringVar()
        self.number.set(1)
        spinboxNumber=Spinbox(self,from_=1,to=30,increment=1,width=4)
        spinboxNumber.config(textvariable=self.number, font="sans 24", justify="center")
        spinboxNumber.grid(row=1,column=1)
        #Modifier
        labelModifier=Label(self,text="Modifier")
        labelModifier.grid(row=2,column=0)
        self.modifier=StringVar()
        self.modifier.set(0)
        spinboxModifier=Spinbox(self,from_=-5,to=5,increment=1,width=4)
        spinboxModifier.config(textvariable=self.modifier, font="sans 24", justify="center")
        spinboxModifier.grid(row=2,column=1)
        #Hide Checkbox
        labelHide=Label(self, text="Hide")
        labelHide.grid(row=2, column=2)
        self.hide=IntVar()
        self.hide.set(0)
        checkbuttonHide=Checkbutton(self,variable=self.hide)
        checkbuttonHide.grid(row=2,column=3)
        #Result display
        self.result=StringVar()
        self.result.set("")
        labelResult1=Label(self,text="Result")
        labelResult1.grid(row=1, column=4)
        labelResult2=Label(self,text=self.result.get(),relief=SUNKEN,width=4)
        labelResult2.grid(row=1,column=5)
        #Button to roll
        buttonRoll=Button(self,text="Roll!", command=self.roll)
        buttonRoll.grid(row=2,column=5)
        

    def roll(self):
        self.throws=[]
        numberOfDices=int(self.number.get())
        sidesOfDice=int(self.sides.get())
        modifierOfDice=int(self.modifier.get())
        
        for i in range(numberOfDices):
            self.throws.append(rd.randint(1,sidesOfDice))
        self.result.set(str(sum(self.throws)+modifierOfDice))
        labelResult2=Label(self,text=self.result.get(),relief=SUNKEN, width=4)
        labelResult2.grid(row=1,column=5)
开发者ID:jkesselring,项目名称:DnDApp,代码行数:57,代码来源:dice.py

示例11: ProgressCheckButton

class ProgressCheckButton(Frame, Observable):
    def __init__(self, parent, model, index, status_model):
        Frame.__init__(self, parent)
        Observable.__init__(self)
        self.model = model
        self.index = index
        self.status_model = status_model
        self.var = IntVar()
        self.var.set(model.get_checked())
        self.progress_var = IntVar()
        self.progress_status = ProgressStatus.undefined
        self.check_button = Checkbutton(self, text=model.get_label, variable=self.var, command=self._check_changed)
        self.progress_bar = Progressbar(self, orient='horizontal', mode='indeterminate', variable=self.progress_var)
        self.check_button.pack(side=LEFT, fill="both", expand=True)

        self.model.add_listener(self._model_changed)

    def _model_changed(self, new_status):
        model_state = self.model.get_checked()
        gui_state = self.var.get()
        if model_state is not gui_state:
            self.model.set_checked(gui_state)

    def refresh_check(self):
        if self.status_model.is_checked_force_reload():
            self.check_button.select()
        else:
            self.check_button.deselect()

    def is_checked(self):
        return self.var.get()

    def _progress_status_changed(self, new_status):
        self._refresh_progress()

    def _refresh_progress(self):
        status = self.status_model.get_status()
        if not status == self.progress_status:
            if status == ProgressStatus.in_progress:
                self.progress_bar.pack(side=RIGHT, fill="both", expand=True)
            else:
                self.progress_bar.pack_forget()

    def _check_changed(self):
        new_checked = self.var.get()
        if new_checked is not self.model.get_checked():
            self.model.set_checked(new_checked)
        if new_checked is not self.status_model.is_checked():
            self._notify(self.index, new_checked)
开发者ID:tomdoel,项目名称:pyxnatbrowser,代码行数:49,代码来源:progresslistbox.py

示例12: __init__

    def __init__(self, control, *args, **kwargs):
        Frame.__init__(self, *args, **kwargs)
        self.config(padx=2)
        self.queue = Queue()
        self.control = control
        self.disabledWhileRunning = []

        self.formulae = list(map(lambda t: StringVar(self, t), ["x/22.5+4", "50-x*50/180"]))
        self.executionTime = DoubleVar(self, "360")
        self.programSpeed = IntVar(self, "292")
        self.maxTravel = IntVar(self, "-200000")
        self.loadSettings()

        self.createWidgets()
        self.thread = None
开发者ID:basilevs,项目名称:varfill,代码行数:15,代码来源:gui.py

示例13: ProgressListBoxItem

class ProgressListBoxItem(Frame, Observable):
    def __init__(self, parent, model):
        Frame.__init__(self, parent)
        Observable.__init__(self)
        self._model = model

        # Create variables and initialise to zero
        self._checked_var = IntVar()
        self._progress_var = IntVar()
        self._checked_var.set(0)
        self._progress_var.set(0)
        self._current_gui_checked_state = CheckStatus.undefined
        self._current_gui_progress_state = ProgressStatus.undefined

        self.check_button = Checkbutton(self, text=model.get_label(), variable=self._checked_var, command=self._user_check_changed)
        self.progress_bar = Progressbar(self, orient='horizontal', mode='indeterminate', variable=self._progress_var)
        self.check_button.pack(side=LEFT, fill="both", expand=True)

        self._update()
        self._model.add_listener(self._model_changed)

    def _model_changed(self):
        self.update()

    def _update(self):
        # Update check status
        model_check_state = self._model.get_check_status()
        if model_check_state is not self._current_gui_checked_state:
            self._current_gui_checked_state = model_check_state
            # if self.status_model.is_checked_force_reload():
            if model_check_state:
                self.check_button.select()
            else:
                self.check_button.deselect()

        # Update progress status
        model_progress_state = self._model.get_progress_status
        if not model_progress_state == self._current_gui_progress_state:
            self._current_gui_progress_state = model_progress_state
            if model_progress_state == ProgressStatus.in_progress:
                self.progress_bar.pack(side=RIGHT, fill="both", expand=True)
            else:
                self.progress_bar.pack_forget()

    def _user_check_changed(self):
        new_checked = self._checked_var.get()
        if new_checked is not self._model.get_check_status():
            self._model.manual_set_checked(new_checked)
开发者ID:tomdoel,项目名称:pyxnatbrowser,代码行数:48,代码来源:progresslistbox.py

示例14: __init__

 def __init__(self, master, ordinances=False, **kwargs):
     super(Options, self).__init__(master, **kwargs)
     self.ancestors = IntVar()
     self.ancestors.set(4)
     self.descendants = IntVar()
     self.spouses = IntVar()
     self.ordinances = IntVar()
     self.contributors = IntVar()
     self.start_indis = StartIndis(self)
     self.fid = StringVar()
     btn = Frame(self)
     entry_fid = EntryWithMenu(btn, textvariable=self.fid, width=16)
     entry_fid.bind('<Key>', self.enter)
     label_ancestors = Label(self, text=_('Number of generations to ascend'))
     entry_ancestors = EntryWithMenu(self, textvariable=self.ancestors, width=5)
     label_descendants = Label(self, text=_('Number of generations to descend'))
     entry_descendants = EntryWithMenu(self, textvariable=self.descendants, width=5)
     btn_add_indi = Button(btn, text=_('Add a FamilySearch ID'), command=self.add_indi)
     btn_spouses = Checkbutton(self, text='\t' + _('Add spouses and couples information'), variable=self.spouses)
     btn_ordinances = Checkbutton(self, text='\t' + _('Add Temple information'), variable=self.ordinances)
     btn_contributors = Checkbutton(self, text='\t' + _('Add list of contributors in notes'), variable=self.contributors)
     self.start_indis.grid(row=0, column=0, columnspan=3)
     entry_fid.grid(row=0, column=0, sticky='w')
     btn_add_indi.grid(row=0, column=1, sticky='w')
     btn.grid(row=1, column=0, columnspan=2, sticky='w')
     entry_ancestors.grid(row=2, column=0, sticky='w')
     label_ancestors.grid(row=2, column=1, sticky='w')
     entry_descendants.grid(row=3, column=0, sticky='w')
     label_descendants.grid(row=3, column=1, sticky='w')
     btn_spouses.grid(row=4, column=0, columnspan=2, sticky='w')
     if ordinances:
         btn_ordinances.grid(row=5, column=0, columnspan=3, sticky='w')
     btn_contributors.grid(row=6, column=0, columnspan=3, sticky='w')
     entry_ancestors.focus_set()
开发者ID:daleathan,项目名称:getmyancestors,代码行数:34,代码来源:fstogedcom.py

示例15: highlight_pattern

 def highlight_pattern(self, pattern, tag, start="1.0", end="end", regexp=False):
     '''Apply the given tag to all text that matches the given pattern
     If 'regexp' is set to True, pattern will be treated as a regular expression
     '''
     start = self.index(start)
     end = self.index(end)
     self.mark_set("matchStart",start)
     self.mark_set("matchEnd",start)
     self.mark_set("searchLimit", end)
     count = IntVar()
     while True:
         index = self.search(pattern, "matchEnd","searchLimit", count=count, regexp=regexp)
         if index == "": break
         self.mark_set("matchStart", index)
         self.mark_set("matchEnd", "%s+%sc" % (index,count.get()))
         self.tag_add(tag, "matchStart","matchEnd")
开发者ID:mncarbone,项目名称:mundiales,代码行数:16,代码来源:dbeditor.py


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