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


Python Radiobutton.place方法代码示例

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


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

示例1: select_start_options

# 需要导入模块: from Tkinter import Radiobutton [as 别名]
# 或者: from Tkinter.Radiobutton import place [as 别名]
  def select_start_options(self):
    '''
    popup box to select side and difficulty levels
    '''
    print 'select game start options'

    popup = Toplevel(self.gui, width=300, height=110)
    popup.title('Choose Game Side and Level')

    # stays on top of the game canvass
    popup.transient(self.gui)
    popup.grab_set()

    # bind window close events
    popup.bind('<Escape>', lambda e: self.not_selected_start_options(popup))
    popup.protocol("WM_DELETE_WINDOW", lambda : self.not_selected_start_options(popup))

    # choose side
    label1 = Label(popup, text="Side", height=30, width=50)
    label1.place(x=10, y=5, height=30, width=50)

    val1 = IntVar()

    bt_north = Radiobutton(popup, text="White", variable=val1, value=1)
    bt_north.place(x=60, y=10)
    bt_south = Radiobutton(popup, text="Black", variable=val1, value=2)
    bt_south.place(x=120, y=10)

    # by default, human plays first, meaning play the north side
    if self.choose_side == 'north':
      bt_north.select()
    else:
      bt_south.select()

    # choose difficulty level
    label2 = Label(popup, text="Level", height=30, width=50)
    label2.place(x=10, y=35, height=30, width=50)

    val2 = IntVar()

    bt_level1 = Radiobutton(popup, text="Dumb", variable=val2, value=1)
    bt_level1.place(x=60, y=40)
    bt_level2 = Radiobutton(popup, text="Smart", variable=val2, value=2)
    bt_level2.place(x=120, y=40)
    bt_level3 = Radiobutton(popup, text="Genius", variable=val2, value=3)
    bt_level3.place(x=180, y=40)

    # by default, the game is medium level
    if self.choose_level == 1:
      bt_level1.select()
    elif self.choose_level == 2:
      bt_level2.select()
    elif self.choose_level == 3:
      bt_level3.select()

    button = Button(popup, text='SET', \
              command=lambda: self.selected_start_options(popup, val1, val2))

    button.place(x=70, y=70)
开发者ID:Caicai1124,项目名称:Artificial-Intelligence,代码行数:61,代码来源:tkui.py

示例2: init

# 需要导入模块: from Tkinter import Radiobutton [as 别名]
# 或者: from Tkinter.Radiobutton import place [as 别名]
def init():
    """初始化页面"""
    global user, offset, photo, url, buy_house, buy_car, age, height, salary, \
        education, company, industry, school, position, satisfy, appearance
    get_user(offset)
    image_url = u'{}&quality=85&thumbnail=410y410'.format(user['avatar'])
    place_image(image_url)

    photo = Label(master, image=tk_image)
    photo.place(anchor=u'nw', x=10, y=40)
    url = Label(master, text=user['url'], font=Font(size=20, weight='bold'))
    url.place(anchor=u'nw', x=10, y=5)
    buy_house = Label(master, text=BUY_HOUSE.get(user['house']) or user['house'])
    buy_house.place(anchor=u'nw', x=490, y=50)
    buy_car = Label(master, text=BUY_CAR.get(user['car']) or user['car'])
    buy_car.place(anchor=u'nw', x=490, y=75)
    age = Label(master, text=user['age'])
    age.place(anchor=u'nw', x=490, y=100)
    height = Label(master, text=user['height'])
    height.place(anchor=u'nw', x=490, y=125)
    salary = Label(master, text=SALARY.get(user['salary']) or user['salary'])
    salary.place(anchor=u'nw', x=490, y=150)
    education = Label(master, text=EDUCATION.get(user['education']) or user['education'])
    education.place(anchor=u'nw', x=490, y=175)
    company = Label(master, text=user['company'] if user['company'] else u'--')
    company.place(anchor=u'nw', x=490, y=200)
    industry = Label(master, text=INDUSTRY.get(user['industry']) or user['industry'])
    industry.place(anchor=u'nw', x=490, y=225)
    school = Label(master, text=user['school'] if user['school'] else u'--')
    school.place(anchor=u'nw', x=490, y=250)
    position = Label(master, text=POSITION.get(user['position']) or user['position'])
    position.place(anchor=u'nw', x=490, y=275)

    satisfy = IntVar()
    satisfy.set(int(user.get(u'satisfy', -1)))
    satisfied = Radiobutton(master, text=u"满意", variable=satisfy,
                            value=1, command=set_satisfy)
    not_satisfied = Radiobutton(master, text=u"不满意", variable=satisfy,
                                value=0, command=set_satisfy)
    satisfied.place(anchor=u'nw', x=450, y=10)
    not_satisfied.place(anchor=u'nw', x=510, y=10)

    appearance = IntVar()
    appearance.set(int(user.get(u'appearance', -1)))
    for i in range(1, 11):
        score_i = Radiobutton(master, text=str(i), variable=appearance,
                              value=i, command=set_appearance)
        score_i.place(anchor=u'nw', x=i * 40 - 30, y=460)
开发者ID:WiseDoge,项目名称:huatian-funny,代码行数:50,代码来源:mark.py

示例3: initUI

# 需要导入模块: from Tkinter import Radiobutton [as 别名]
# 或者: from Tkinter.Radiobutton import place [as 别名]
    def initUI(self):
        """
        Initializes the user interface

        Setting up the entry widgets for:
        - Experiment_ID
        - Participant Name
        - Session Day
        - Pupil Size
        - Practice
        - Stereo
        """
        # Set the title
        self.parent.title(EXP_NAME)

        # Create the label for Experiment_ID and set location
        label_id = Label(text='Participant ID:')
        label_id.place(x=20, y=20)

        # Check the DATA_DIR directory for previous participants
        # and choose the next Experiment_ID in line
        self.folders = listdir(DATA_DIR)
        # Initiate Tkinter's StringVar
        self.value_id = StringVar()
        # Set the default value
        self.value_id.set('001')
        # Going in reverse order of the participants' directories in
        # DATA_DIR, find the last participant's Experiment_ID and opt
        # for the next one in line
        for folder in reversed(self.folders):
            try:
                # Check if the value of the first 3 digits of the
                # directory name is greater than the default value
                if int(folder[:3]) >= int(self.value_id.get()):
                    # Get the next Experiment_ID in integer form and
                    # convert to string format
                    num = str(int(folder[:3]) + 1)
                    # Actions to perform in case scenarios for each
                    # of the possibilites of num_length
                    num_length = {
                                  3: num,
                                  2: '0%s' % num,
                                  1: '00%s' % num
                    }
                    # Set the value accordingly to the StringVar,
                    # replacing the default
                    self.value_id.set(num_length[len(num)])
            # In case there are other folders in DATA_DIR, for which
            # the first 3 characters are not digits, we must cater
            # for when an exception is thrown up
            except ValueError:
                pass
        # Create the entry widget for Experiment_ID with the preset
        # value and state disabled
        self.input_id = Entry(self.parent, width=5, state=DISABLED,
                              textvariable=self.value_id)
        self.input_id.place(x=150, y=20)

        # Create the label for Participant Name and set location
        label_name = Label(text='Participant Name:')
        label_name.place(x=20, y=50)

        # Initiate Tkinter's StringVar
        self.value_name = StringVar()
        # Set the default value
        self.value_name.set('')
        # Create the entry for Participant Name and set location
        self.input_name = Entry(self.parent, width=35,
                                textvariable=self.value_name)
        self.input_name.place(x=150, y=50)
        self.input_name.focus()

        # Create the label for Session Day and set location
        label_day = Label(text='Session Day:')
        label_day.place(x=20, y=80)

        # Create value holder for Session Day as IntVar and set default
        # value to 1
        self.value_day = IntVar()
        self.value_day.set(1)
        # Create the radiobuttons as required
        for day in range(1, TOTAL_SESSIONS + 1):
            input_day = Radiobutton(self.parent, text=str(day),
                                    variable=self.value_day, value=day)
            # Anchor them to the West (W)
            input_day.pack(anchor=W)
            # Choose location for the radiobuttons
            input_day.place(x=150, y=(50 + (day * 25)))

        # Create the label for Pupil Size and set location
        label_pupilsize = Label(text='Pupil Size:')
        label_pupilsize.place(x=20, y=140)

        self.value_pupilsize = StringVar()
        self.value_pupilsize.set('')
        # Create the MaxLengthEntry for Pupil Size and set location
        # The maximum length is set to 3 characters and a float must be
        # provided
        self.input_pupilsize = MaxLengthEntry(self.parent, width=5,
                                              maxlength=3,
#.........这里部分代码省略.........
开发者ID:kkalou,项目名称:3DSlantRelief,代码行数:103,代码来源:participant.py


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