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


Python tkinter.Radiobutton方法代码示例

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


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

示例1: threaded_check_video

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Radiobutton [as 别名]
def threaded_check_video(self):
        self.last_row = 0
        self.stream.set(0)
        [radio_button.destroy() for radio_button in self.stream_widgets]
        url = self.text_url.get()
        if 'https' not in url:
            url = 'https://www.youtube.com/watch?v=%s' % url
        try:
            if self.proxy.get() != '':
                self.video = YouTube(url, proxies={self.proxy.get().split(':')[0]: self.proxy.get()})
            else:
                self.video = YouTube(url)
            self.label_video_title['text'] = self.video.title
            self.streams = self.video.streams.filter(only_audio=self.audio_only.get()).all()

            for stream in self.streams:
                if self.audio_only.get():
                    text = f'Codec: {stream.audio_codec}, ' \
                           f'ABR: {stream.abr} ' \
                           f'File Type: {stream.mime_type.split("/")[1]}, Size: {stream.filesize // 1024} KB'
                else:
                    if stream.video_codec is None:
                        continue
                    text = f'Res: {stream.resolution}, FPS: {stream.fps},' \
                           f' Video Codec: {stream.video_codec}, Audio Codec: {stream.audio_codec}, ' \
                           f'File Type: {stream.mime_type.split("/")[1]}, Size: {stream.filesize // 1024} KB'
                radio_button = tk.Radiobutton(self.frame, text=text, variable=self.stream, value=stream.itag)
                self.last_row += 1
                radio_button.grid(row=self.last_row, column=0, columnspan=4)
                self.stream_widgets.append(radio_button)
        except PytubeError as e:
            messagebox.showerror('Something went wrong...', e)
        except RegexMatchError as e:
            messagebox.showerror('Something went wrong...', e)
        finally:
            self.btn_check_id['text'] = 'Check Video'
            self.btn_check_id.config(state=tk.NORMAL) 
开发者ID:mraza007,项目名称:videodownloader,代码行数:39,代码来源:gui.py

示例2: select_layer_rb

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Radiobutton [as 别名]
def select_layer_rb(self):
        """Select layer."""
        if hasattr(self, 'layer_frame'):
            self.layer_frame.pack_forget()
            self.layer_frame.destroy()
        self.layer_frame = tk.LabelFrame(self.graph_frame, labelanchor='nw',
                                         text="Select layer", relief='raised',
                                         borderwidth='3', bg='white')
        self.layer_frame.pack(side='bottom', fill=None, expand=False)
        self.plots_dir = os.path.join(self.gui_log.get(),
                                      self.selected_plots_dir.get())
        if os.path.isdir(self.plots_dir):
            layer_dirs = [d for d in sorted(os.listdir(self.plots_dir))
                          if d != 'normalization' and
                          os.path.isdir(os.path.join(self.plots_dir, d))]
            [tk.Radiobutton(self.layer_frame, bg='white', text=name,
                            value=name, command=self.display_graphs,
                            variable=self.layer_to_plot).pack(
                fill='both', side='bottom', expand=True)
                for name in layer_dirs] 
开发者ID:NeuromorphicProcessorProject,项目名称:snn_toolbox,代码行数:22,代码来源:gui.py

示例3: crear_widgets

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Radiobutton [as 别名]
def crear_widgets(self):

        self.var = IntVar()
        self.background_label = Label(self.container,
                                      image=self.imagen_fondo)
        txt = "Selecciona una choza en la que entrar. Ganarás si:\n"
        txt += "La choza está vacia o si su ocupante es tu aliado, de lo contrario morirás"
        self.info_label = Label(self.container, text=txt, bg='white')
        # Creamos un dicionario con las opciones para las imagenes de las chozas
        r_btn_config = {'variable': self.var,
                        'bg': '#8AA54C',
                        'activebackground': 'green',
                        'image': self.imagen_choza,
                        'height': self.alto_choza,
                        'width': self.ancho_choza,
                        'command': self.radio_btn_pressed}

        self.r1 = Radiobutton(self.container, r_btn_config, value=1)
        self.r2 = Radiobutton(self.container, r_btn_config, value=2)
        self.r3 = Radiobutton(self.container, r_btn_config, value=3)
        self.r4 = Radiobutton(self.container, r_btn_config, value=4)
        self.r5 = Radiobutton(self.container, r_btn_config, value=5) 
开发者ID:tidus747,项目名称:Tutoriales_juegos_Python,代码行数:24,代码来源:juegochozas.py

示例4: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Radiobutton [as 别名]
def __init__(self,gui,sw_index,switchCtrl):
    #Add the buttons to window
    self.msgType=TK.IntVar()
    self.msgType.set(SC.MSGOFF)
    self.btn = TK.Button(gui,
                  text=sw_list[sw_index][SW_NAME],
                  width=30, command=self.sendMsg,
                  bg=SW_COLOR[self.msgType.get()])
    self.btn.pack()
    msgOn = TK.Radiobutton(gui,text="On",
              variable=self.msgType, value=SC.MSGON)
    msgOn.pack()
    msgOff = TK.Radiobutton(gui,text="Off",
              variable=self.msgType,value=SC.MSGOFF)
    msgOff.pack()
    self.sw_num=sw_list[sw_index][SW_CMD]
    self.sw_ctrl=switchCtrl 
开发者ID:PacktPublishing,项目名称:Raspberry-Pi-3-Cookbook-for-Python-Programmers-Third-Edition,代码行数:19,代码来源:socketMenu.py

示例5: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Radiobutton [as 别名]
def __init__(self, master, text, value, variable, command=None, grid=None, align=None, visible=True, enabled=None):

        description = "[RadioButton] object with option=\"" + str(text) + "\" value=\"" + str(value) + "\""
        self._text = text
        self._value = value

        # `variable` is the externally passed StringVar keeping track of which
        # option was selected. This class should not be instantiated by a user
        # unless they know what they are doing.
        tk = Radiobutton(master.tk, text=self._text, value=self._value, variable=variable)

        super(RadioButton, self).__init__(master, tk, description, grid, align, visible, enabled, None, None)

    # PROPERTIES
    # -----------------------------------

    # The value of this button 
开发者ID:lawsie,项目名称:guizero,代码行数:19,代码来源:RadioButton.py

示例6: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Radiobutton [as 别名]
def __init__(self):
        super().__init__()
        self.title("Tk themed widgets")

        var = tk.StringVar()
        var.set(self.greetings[0])
        label_frame = ttk.LabelFrame(self, text="Choose a greeting")
        for greeting in self.greetings:
            radio = ttk.Radiobutton(label_frame, text=greeting,
                                    variable=var, value=greeting)
            radio.pack()

        frame = ttk.Frame(self)
        label = ttk.Label(frame, text="Enter your name")
        entry = ttk.Entry(frame)

        command = lambda: print("{}, {}!".format(var.get(), entry.get()))
        button = ttk.Button(frame, text="Greet", command=command)

        label.grid(row=0, column=0, padx=5, pady=5)
        entry.grid(row=0, column=1, padx=5, pady=5)
        button.grid(row=1, column=0, columnspan=2, pady=5)

        label_frame.pack(side=tk.LEFT, padx=10, pady=10)
        frame.pack(side=tk.LEFT, padx=10, pady=10) 
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Application-Development-Cookbook,代码行数:27,代码来源:chapter8_01.py

示例7: __make_radio_button

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Radiobutton [as 别名]
def __make_radio_button(self,frame, row, column, text, val, var):
        tk.Radiobutton(frame, text=text, width=5,
                       variable=var, value=val).grid(row=row, column=column) 
开发者ID:liucaide,项目名称:Andromeda,代码行数:5,代码来源:ui_input.py

示例8: add_radio_button

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Radiobutton [as 别名]
def add_radio_button(self, text, index):

        maptype = self.maptypes[index]
        tk.Radiobutton(self.radiogroup, text=maptype, variable=self.radiovar, value=index, 
                command=lambda:self.usemap(maptype)).grid(row=0, column=index) 
开发者ID:dark-archerx,项目名称:Traffic-Signs-and-Object-Detection,代码行数:7,代码来源:example.py

示例9: addOption

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Radiobutton [as 别名]
def addOption(self, title, function):
        button = tk.Radiobutton(self, text=title, command=lambda:function(title), 
                                indicatoron=0, value=self.counter,
                                selectcolor="#00FFFF", bg="#FFFFFF",
                                compound="top")
        font = tkFont.Font(font=button['font'])
        font.config(weight='bold')
        button['font'] = font
        button.grid(row=self.counter, column="0", sticky="ew")
        if self.counter == 0:
            button.select()
            
        try:
            chosenImage = self.images[title]
        except KeyError:
            chosenImage = "gear.png"
            
        try:
            image = tk.PhotoImage(file=sys._MEIPASS + '\\images\\' + chosenImage)
            button.configure(image=image)
            button.image = image
        except Exception:
            try:
                path = os.path.join('PyEveLiveDPS', 'images', chosenImage)
                image = tk.PhotoImage(file=path)
                button.configure(image=image)
                button.image = image
            except Exception as e:
                pass
                
        self.counter += 1 
开发者ID:ArtificialQualia,项目名称:PyEveLiveDPS,代码行数:33,代码来源:settingsWindow.py

示例10: create_radio

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Radiobutton [as 别名]
def create_radio(self,setting,pos):
    self.radios[setting.name] = tk.IntVar()
    f = tk.Frame(self.root)
    f.grid(row=pos+2,column=1,sticky=tk.E+tk.W)
    tk.Label(f,text=setting.name+":").pack(anchor=tk.W)
    for k,v in setting.limits.items():
      r = tk.Radiobutton(f,text=k,variable=self.radios[setting.name],value=v)
      if setting.value == v:
        r.select()
      r.pack(anchor=tk.W) 
开发者ID:LaboratoireMecaniqueLille,项目名称:crappy,代码行数:12,代码来源:cameraConfig.py

示例11: checkCallback

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Radiobutton [as 别名]
def checkCallback(self, *ignored_args):
        # only enable one checkbutton
        if self.chVarUn.get(): self.check3.configure(state='disabled')
        else:                  self.check3.configure(state='normal')
        if self.chVarEn.get(): self.check2.configure(state='disabled')
        else:                  self.check2.configure(state='normal') 
        
    # Radiobutton Callback 
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Second-Edition,代码行数:10,代码来源:GUI_URL.py

示例12: checkCallback

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Radiobutton [as 别名]
def checkCallback(self, *ignoredArgs):
        # only enable one checkbutton
        if self.chVarUn.get(): self.check3.configure(state='disabled')
        else:                  self.check3.configure(state='normal')
        if self.chVarEn.get(): self.check2.configure(state='disabled')
        else:                  self.check2.configure(state='normal') 
        
    # Radiobutton callback function 
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Second-Edition,代码行数:10,代码来源:GUI.py

示例13: checkCallback

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Radiobutton [as 别名]
def checkCallback(self, *ignoredArgs):
        # only enable one checkbutton
        if self.chVarUn.get(): self.check3.configure(state='disabled')
        else:             self.check3.configure(state='normal')
        if self.chVarEn.get(): self.check2.configure(state='disabled')
        else:             self.check2.configure(state='normal') 
        
    # Radiobutton callback function 
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Second-Edition,代码行数:10,代码来源:GUI_MySQL.py


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