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


Python OptionMenu.place方法代码示例

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


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

示例1: MusicGUI

# 需要导入模块: from Tkinter import OptionMenu [as 别名]
# 或者: from Tkinter.OptionMenu import place [as 别名]
class MusicGUI(Frame):
  
    def __init__(self, parent):
        Frame.__init__(self, parent)   
         
        self.parent = parent
        self.centerWindow()
        self.initUI()

    def centerWindow(self):
        w = 500
        h = 500

        sw = self.parent.winfo_screenwidth()
        sh = self.parent.winfo_screenheight()

        x = (sw - w) / 2
        y = (sh - h) / 2
        self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))

    def initUI(self):
      
        self.parent.title("Python-Kullita")

        self.pack(fill=BOTH, expand=True)
        # self.var = BooleanVar()
        L1 = Label(self, text="Midi File Name:")
        L1.place(x = 30, y = 450)
        self.fileEntry = Entry(self)
        self.fileEntry.place(x = 150, y = 450)
        genButton = Button(self, text="Genrate Music!",
             command=self.onClick)
        genButton.place(x=350, y=450)
        self.initLog()
        self.init3Voices()

    def init3Voices(self):
        # [(47, 67), (52, 76), (60, 81)])
        # (B,2) - 20
        # (E,3) - 24
        # (C,4) - 25
        self.note_name = ['C','Cs','D','Ds','E','F','Fs','G','Gs','A','As','B']
        self.pitchC1 = StringVar()
        self.pitchC2 = StringVar()
        self.pitchC3 = StringVar()
        self.octave1 = IntVar()
        self.octave2 = IntVar()
        self.octave3 = IntVar()
        self.range1 = IntVar()
        self.range2 = IntVar()
        self.range3 = IntVar()


        v1Label =Label(self, text="Voice 1 start:")
        v1Label.place(x = 30, y = 25)
        self.w1 = OptionMenu(self, self.pitchC1, *self.note_name)
        self.w1.place(x = 135, y = 25)
        self.pitchC1.set(self.note_name[11])
        self.oc1 = OptionMenu(self, self.octave1, *range(1, 9))
        self.oc1.place(x=200, y=25)
        self.octave1.set(2)
        v1_rangeLabel = Label(self, text="Range:")
        v1_rangeLabel.place(x=300, y=25)
        self.rangeoption1 = OptionMenu(self, self.range1, *range(18, 26))
        self.rangeoption1.place(x=360, y=25)
        self.range1.set(20)


        v2Label = Label(self, text="Voice 2 start:")
        v2Label.place(x=30, y=50)
        self.w2 = OptionMenu(self, self.pitchC2, *self.note_name)
        self.w2.place(x=135, y=50)
        self.pitchC2.set(self.note_name[4])
        self.oc2 = OptionMenu(self, self.octave2, *range(1, 9))
        self.oc2.place(x=200, y=25 * 2)
        self.octave2.set(3)
        v2_rangeLabel = Label(self, text="Range:")
        v2_rangeLabel.place(x=300, y=25 * 2)
        self.rangeoption2 = OptionMenu(self, self.range2, *range(18, 26))
        self.rangeoption2.place(x=360, y=25 * 2)
        self.range2.set(24)


        v3Label = Label(self, text="Voice 3 start:")
        v3Label.place(x=30, y=75)
        self.w3 = OptionMenu(self, self.pitchC3, *self.note_name)
        self.w3.place(x=135, y=75)
        self.pitchC3.set(self.note_name[0])
        self.oc3 = OptionMenu(self, self.octave3, *range(1, 9))
        self.oc3.place(x=200, y=25 * 3)
        self.octave3.set(4)
        v3_rangeLabel = Label(self, text="Range:")
        v3_rangeLabel.place(x=300, y=25 * 3)
        self.rangeoption3 = OptionMenu(self, self.range3, *range(18, 26))
        self.rangeoption3.place(x=360, y=25 * 3)
        self.range3.set(25)

    # def pitchClick(self, voiceStr, key):
    #     print("hello!")
    #     vMap = {'1': self.pitchC1, '2': self.pitchC2, '3': self.pitchC3}
#.........这里部分代码省略.........
开发者ID:donya,项目名称:PythonKulitta,代码行数:103,代码来源:ExampleGUI.py


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