Esempio n. 1
0
def makemenu(parent):
    '''
    Builds the menu
    :param parent: the parent component
    '''
    menubar = Frame(parent)  # relief=RAISED, bd=2...
    menubar.pack(side=TOP, fill=X)

    fbutton = Menubutton(menubar, text='File', underline=0)
    fbutton.pack(side=LEFT)

    file = Menu(fbutton)
    file.add_command(label='New...', command=notdone, underline=0)
    file.add_command(label='Open...', command=notdone, underline=0)
    file.add_command(label='Quit', command=parent.quit, underline=0)
    fbutton.config(menu=file)

    ebutton = Menubutton(menubar, text='Edit', underline=0)
    ebutton.pack(side=LEFT)

    edit = Menu(ebutton, tearoff=False)
    edit.add_command(label='Cut', command=notdone, underline=0)
    edit.add_command(label='Paste', command=notdone, underline=0)
    edit.add_separator()
    ebutton.config(menu=edit)

    submenu = Menu(edit, tearoff=True)
    submenu.add_command(label='Spam', command=parent.quit, underline=0)
    submenu.add_command(label='Eggs', command=notdone, underline=0)
    edit.add_cascade(label='Stuff', menu=submenu, underline=0)
    return menubar
Esempio n. 2
0
 def make_file_type_menu(self, menubar):
     _, e = os.path.splitext(self.file)
     ext = e[1:]
     if ext == "py":
         pybtn = Menubutton(menubar, text='Python', name=ext)
         pybtn.pack(side=LEFT)
         py = Menu(pybtn, tearoff=0)
         py.add_command(label='Compile',
                        command=self.compile_python,
                        accelerator="Ctrl+F5")
         py.add_command(label='Run',
                        command=self.run_python,
                        accelerator="F5")
         pybtn.config(menu=py)
         self.bind_all("<Control-F5>", self.compile_python)
         self.bind_all("<F5>", self.run_python)
     elif ext == "tcl":
         tclbtn = Menubutton(menubar, text='TCL', name=ext)
         tclbtn.pack(side=LEFT)
         tcl = Menu(tclbtn, tearoff=0)
         tcl.add_command(label='Run',
                         command=self.run_tcl,
                         accelerator="F5")
         tclbtn.config(menu=tcl)
         self.bind_all("<F5>", self.run_tcl)
Esempio n. 3
0
    def task_list(self):
        fr = Frame(self)
        fr_top = Frame(fr)
        task_lbx = Listbox(fr_top)
        task_lbx.pack(anchor="center",
                      fill="both",
                      expand=True,
                      padx=3,
                      pady=3)
        self._task_box = task_lbx

        fr_bot = Frame(fr, height='2')
        b1 = Menubutton(fr_bot, text='실행메뉴')
        b1.menu = Menu(b1, tearoff=0)
        b1['menu'] = b1.menu
        b1.menu.add_command(label='실행', command=self.convert)
        b1.menu.add_command(label='비우기', command=self.delete_task_item)
        b1.pack()

        fr_top.pack(side='top', fill='both', expand=True)
        fr_bot.pack(side='bottom', fill='x')
        task_lbx.config(highlightcolor='green',
                        font=('굴림체', 10),
                        activestyle='none',
                        selectmode='extended')

        self.task_lbx = task_lbx

        return fr
Esempio n. 4
0
    def inicializar_gui(self):
        lbl_titulo = Label(self.master, text='Lenguajes programación', font='31')
        lbl_titulo.pack()

        mbn_lenguajes = Menubutton(self.master, text='Menú lenguajes')

        mbn_lenguajes.menu = Menu(mbn_lenguajes)
        mbn_lenguajes['menu'] = mbn_lenguajes.menu

        var_javascript = IntVar()
        var_python = IntVar()
        var_java = IntVar()

        mbn_lenguajes.menu.add_command(label = 'JavaScript', command=self.mostrar_mensaje)
        mbn_lenguajes.menu.add_command(label = 'Python', command=self.mostrar_mensaje)
        mbn_lenguajes.menu.add_command(label = 'Java', command=self.mostrar_mensaje)

        mbn_lenguajes.pack()
Esempio n. 5
0
    def _make_menu_bar(self):
        """
        make menu bar at the top (TK9.0 menus below)
        expand=no, fill=X so same width on resize
        """
        menu_bar = Frame(self, relief=RAISED, bd=2)
        menu_bar.pack(side=TOP, fill=X)

        for (name, key, items) in self.menu_bar:
            mbutton = Menubutton(menu_bar, text=name, underline=key)
            mbutton.pack(side=LEFT)
            pulldown = Menu(mbutton)
            self._add_menu_items(pulldown, items)
            mbutton.config(menu=pulldown)

        if self.help_button:
            Button(menu_bar,
                   text='Help',
                   cursor='gumby',
                   relief=FLAT,
                   command=self.help).pack(side=RIGHT)
Esempio n. 6
0
    def make_menu(self):
        self.menubar = Frame(self)
        self.menubar.pack(side=TOP)

        filebtn = Menubutton(self.menubar, text='File')
        filebtn.pack(side=LEFT)
        file = Menu(filebtn, tearoff=0)
        file.add_command(label='New', command=self.new, accelerator="Ctrl+N")
        file.add_command(label='Save', command=self.save, accelerator="Ctrl+S")
        file.add_command(label='Quit', command=self.quit, accelerator="Ctrl+Q")
        filebtn.config(menu=file)

        editbtn = Menubutton(self.menubar, text='Edit')
        editbtn.pack(side=LEFT)
        edit = Menu(editbtn, tearoff=0)
        edit.add_command(label='Cut', command=self.cut)
        edit.add_command(label='Copy', command=self.copy)
        edit.add_command(label='Paste', command=self.paste)
        editbtn.config(menu=edit)

        if self.file:
            self.make_file_type_menu(self.menubar)
Esempio n. 7
0
    def component_list(self):
        #sandy brown
        fr1 = Frame(self)
        scrollbar = Scrollbar(fr1)
        scrollbar.pack(side="right", fill="y")

        self._list = Listbox(fr1,
                             bg="dim grey",
                             fg="white",
                             width=20,
                             yscrollcommand=scrollbar.set)

        mb1 = Menubutton(fr1, text='선택메뉴', relief='flat', bg='steel blue3')
        mb1.menu = Menu(mb1, tearoff=0)
        mb1['menu'] = mb1.menu
        mb1.menu.add_command(label='등록', command=self.choose_all)
        mb1.pack(side='bottom')
        mb1.menu.add_command(label='선택',
                             command=lambda: self._list.select_set(0, END))
        mb1.menu.add_command(
            label='해제', command=lambda: self._list.selection_clear(0, 'end'))

        self._list.pack(anchor="center",
                        fill="both",
                        expand=True,
                        padx=3,
                        pady=3)

        scrollbar.config(command=self._list.yview)
        self._list.config(highlightcolor='green',
                          font=('나눔고딕', 10),
                          activestyle='none',
                          selectmode='extended')

        self._list.bind('<<ListboxSelect>>', self.select_item)
        self._list.bind('<Button-3>', self.sub_menu1)
        self._list.exportselection = 0

        return fr1
Esempio n. 8
0
    def __init__(self, *args, **kwargs):
        Page.__init__(self, *args, **kwargs)

        self.configuration = Configuration().load_configuration()
        self.api = WalletAPI()
        self.tokens = self.api.list_tokens(self.configuration)
        self.eth_balance, _ = self.api.get_balance(self.configuration)

        def change_token(token):
            if token == 'ETH':
                self.eth_balance, _ = self.api.get_balance(self.configuration)
            else:
                self.eth_balance, _ = self.api.get_balance(self.configuration, token)

            balance.set(str(self.eth_balance) + ' ' + token)

        token_symbol = StringVar()
        token_symbol.set('ETH')
        balance = StringVar()
        balance.set(str(self.eth_balance) + ' ' + token_symbol.get())

        mb = Menubutton(self,
                        width=60,
                        textvariable=token_symbol,
                        relief=RAISED)
        mb.grid()
        mb.menu = Menu(mb, tearoff=0)
        mb["menu"] = mb.menu
        mb.menu.add_radiobutton(label="ETH",
                                variable=token_symbol,
                                value='ETH',
                                command=lambda: change_token(token_symbol.get()))
        for token in self.tokens:
            mb.menu.add_radiobutton(label=token,
                                    variable=token_symbol,
                                    value=token,
                                    command=lambda: change_token(token_symbol.get()))
        mb.pack()

        label = Label(self,
                      textvariable=balance,
                      width=60,
                      font=(None, 30))
        label.pack()

        lbl_address = Label(self,
                            text="To address:",
                            width=60,
                            font=(None, 20))
        lbl_address.pack()

        entry_address = Entry(self,
                              font=(None, 20),
                              width=60,
                              justify=CENTER)
        entry_address.pack()

        lbl_amount = Label(self,
                           text="Amount:",
                           width=60,
                           font=(None, 20))
        lbl_amount.pack()

        entry_amount = Entry(self,
                             font=(None, 20),
                             width=60,
                             justify=CENTER)
        entry_amount.pack()

        lbl_passphrase = Label(self,
                               text="Passphrase:",
                               width=60,
                               font=(None, 20))
        lbl_passphrase.pack()

        entry_passphrase = Entry(self,
                                 font=(None, 20),
                                 width=60,
                                 justify=CENTER)
        entry_passphrase.pack()

        btn_send = Button(self,
                          text="Send",
                          width=60,
                          font=(None, 16),
                          command=lambda: self.send_transaction(entry_address.get(),
                                                                entry_amount.get(),
                                                                entry_passphrase.get(),
                                                                token_symbol.get()))
        btn_send.pack()

        btn_back = Button(self,
                          text="Back",
                          width=60,
                          font=(None, 16),
                          command=self.navigate_home_page)
        btn_back.pack()
Esempio n. 9
0
    def __init__(self, *args, **kwargs):
        Page.__init__(self, *args, **kwargs)

        self.configuration = Configuration().load_configuration()
        self.api = WalletAPI()
        self.tokens = self.api.list_tokens(self.configuration)
        self.eth_balance, self.address = self.api.get_balance(self.configuration)

        def refresh():
            change_token(token_symbol.get())

        def change_token(token):
            if token == 'ETH':
                self.eth_balance, self.address = self.api.get_balance(self.configuration)
            else:
                self.eth_balance, self.address = self.api.get_balance(self.configuration, token)
            balance.set(str(self.eth_balance) + ' ' + token)

        token_symbol = StringVar()
        token_symbol.set('ETH')
        balance = StringVar()
        balance.set(str(self.eth_balance) + ' ' + token_symbol.get())

        mb = Menubutton(self,
                        width=60,
                        textvariable=token_symbol,
                        relief=RAISED)
        mb.grid()
        mb.menu = Menu(mb, tearoff=0)
        mb["menu"] = mb.menu
        mb.menu.add_radiobutton(label="ETH",
                                variable=token_symbol,
                                value='ETH',
                                command=lambda: change_token(token_symbol.get()))
        for token in self.tokens:
            mb.menu.add_radiobutton(label=token,
                                    variable=token_symbol,
                                    value=token,
                                    command=lambda: change_token(token_symbol.get()))
        mb.menu.add_radiobutton(label="Add new token ...",
                                command=self.navigate_add_token_page)
        mb.pack()

        label_address_lbl = Label(self,
                                  text='Address:',
                                  width=60,
                                  font=(None, 10, "bold"))
        label_address_lbl.pack()
        label_address = Label(self,
                              text=self.address,
                              width=60,
                              font=(None, 10))
        label_address.pack()

        label_balance = Label(self,
                              textvariable=balance,
                              width=60,
                              font=(None, 30))
        label_balance.pack()

        btn_refresh = Button(self,
                             text="Refresh",
                             command=refresh,
                             width=60,
                             font=(None, 16))
        btn_refresh.pack()

        btn_copy_address = Button(self,
                                  text="Copy address",
                                  command=self.copy_address,
                                  width=60,
                                  font=(None, 16))
        btn_copy_address.pack()

        btn_send_transaction = Button(self,
                                      text="Send Transaction",
                                      command=self.navigate_transaction_page,
                                      width=60,
                                      font=(None, 16))
        btn_send_transaction.pack()
Esempio n. 10
0
"""
    Menubutton example
"""
from tkinter import Tk, Menubutton, Menu
from tkinter import RAISED

root = Tk()
mbutton = Menubutton(root, text='Food')  # the pull-down stands alone
picks = Menu(mbutton)
mbutton.config(menu=picks)
picks.add_command(label='spam', command=root.quit)
picks.add_command(label='eggs', command=root.quit)
picks.add_command(label='bacon', command=root.quit)
mbutton.pack()
mbutton.config(bg='white', bd=4, relief=RAISED)
root.mainloop()
Esempio n. 11
0

def toggleJavaFun():
    print("Java " + str(variablejava.get()))


def toggleRadio():
    print("Radio : " + str(radio_val.get()))


frame = Frame(window, relief=RAISED, borderwidth=1)
frame.pack(fill=X)

#First Menu
first_menu = Menubutton(frame, text="File")
first_menu.pack(padx=3, pady=3, side=LEFT)
first_menu.menu = Menu(first_menu, tearoff=False)
first_menu.menu.add_command(label="New", command=newFile)
first_menu.menu.add_command(label="Open", command=openFile)
first_menu.menu.add("separator")
first_menu.menu.add_command(label="Exit", command=exitMenu)
first_menu['menu'] = first_menu.menu

#second Menu
second_menu = Menubutton(frame, text="Edit")
second_menu.pack(padx=3, pady=3, side=LEFT)
second_menu.menu = Menu(second_menu, tearoff=False)
second_menu.menu.add_command(label="DELETE ALL", command=delFile)
second_menu.menu.add_command(label="CLOSE", command=closeFile)
second_menu.menu.add("separator")
second_menu.menu.add_command(label="Exit", command=exitFile)
Esempio n. 12
0
class lightingPanel(AppShell):
    #################################################################
    # lightingPanel(AppShell)
    # This will create a window to let user
    # create any kinds of lighting into the scene
    #################################################################
    # Override class variables
    appname = 'Lighting Panel'
    frameWidth = 400
    frameHeight = 400
    currentLight = None

    def __init__(self, lightList, parent=None, **kw):
        self.lightList = lightList
        self.lightColor = [0.3 * 255, 0.3 * 255, 0.3 * 255]
        self.type = ''
        INITOPT = Pmw.INITOPT
        optiondefs = (('title', self.appname, None), )
        self.defineoptions(kw, optiondefs)

        # Initialize the superclass
        AppShell.__init__(self)

        # Execute option callbacks
        self.initialiseoptions(lightingPanel)

        self.parent.resizable(
            False, False)  ## Disable the ability to resize for this Window.

    def createInterface(self):
        # Handle to the toplevels interior
        interior = self.interior()
        menuBar = self.menuBar
        self.menuBar.destroy()

        # Create a frame to hold all stuff
        mainFrame = Frame(interior)

        self.listZone = Pmw.Group(mainFrame, tag_pyclass=None)
        self.listZone.pack(expand=0, fill=tkinter.X, padx=3, pady=3)
        listFrame = self.listZone.interior()

        self.lightEntry = self.createcomponent(
            'Lights List', (),
            None,
            Pmw.ComboBox, (listFrame, ),
            label_text='Light :',
            labelpos=tkinter.W,
            entry_width=25,
            selectioncommand=self.selectLight,
            scrolledlist_items=self.lightList)
        self.lightEntry.pack(side=tkinter.LEFT)

        self.renameButton = self.createcomponent('Rename Light', (),
                                                 None,
                                                 Button, (listFrame, ),
                                                 text=' Rename ',
                                                 command=self.renameLight)
        self.renameButton.pack(side=tkinter.LEFT)

        self.addLighZone = Pmw.Group(listFrame, tag_pyclass=None)
        self.addLighZone.pack(side=tkinter.LEFT)
        insideFrame = self.addLighZone.interior()
        self.lightsButton = Menubutton(insideFrame,
                                       text='Add light',
                                       borderwidth=3,
                                       activebackground='#909090')
        lightsMenu = Menu(self.lightsButton)
        lightsMenu.add_command(label='Add Ambient Light',
                               command=self.addAmbient)
        lightsMenu.add_command(label='Add Directional Light',
                               command=self.addDirectional)
        lightsMenu.add_command(label='Add Point Light', command=self.addPoint)
        lightsMenu.add_command(label='Add Spotlight', command=self.addSpot)

        self.lightsButton.pack(expand=0)
        self.lightsButton['menu'] = lightsMenu

        self.deleteButton = self.createcomponent('delete Light', (),
                                                 None,
                                                 Button, (listFrame, ),
                                                 text='  Delete  ',
                                                 command=self.deleteLight)
        self.deleteButton.pack(side=tkinter.LEFT)

        self.lightColor = seColorEntry(mainFrame,
                                       text='Light Color',
                                       value=self.lightColor)
        self.lightColor['command'] = self.setLightingColorVec
        self.lightColor['resetValue'] = [0.3 * 255, 0.3 * 255, 0.3 * 255, 0]
        self.lightColor.pack(fill=tkinter.X, expand=0)
        self.bind(self.lightColor, 'Set light color')

        # Notebook pages for light specific controls
        self.lightNotebook = Pmw.NoteBook(mainFrame,
                                          tabpos=None,
                                          borderwidth=0)
        ambientPage = self.lightNotebook.add('Ambient')
        directionalPage = self.lightNotebook.add('Directional')
        pointPage = self.lightNotebook.add('Point')
        spotPage = self.lightNotebook.add('Spot')
        # Put this here so it isn't called right away
        self.lightNotebook['raisecommand'] = self.updateLightInfo

        # Directional light controls
        self.dSpecularColor = seColorEntry(directionalPage,
                                           text='Specular Color')
        self.dSpecularColor['command'] = self.setSpecularColor
        self.dSpecularColor.pack(fill=tkinter.X, expand=0)
        self.bind(self.dSpecularColor, 'Set directional light specular color')
        self.dPosition = Vector3Entry(directionalPage, text='Position')
        self.dPosition['command'] = self.setPosition
        self.dPosition['resetValue'] = [0, 0, 0, 0]
        self.dPosition.pack(fill=tkinter.X, expand=0)
        self.bind(self.dPosition, 'Set directional light position')
        self.dOrientation = Vector3Entry(directionalPage, text='Orientation')
        self.dOrientation['command'] = self.setOrientation
        self.dOrientation['resetValue'] = [0, 0, 0, 0]
        self.dOrientation.pack(fill=tkinter.X, expand=0)
        self.bind(self.dOrientation, 'Set directional light orientation')

        # Point light controls
        self.pSpecularColor = seColorEntry(pointPage, text='Specular Color')
        self.pSpecularColor['command'] = self.setSpecularColor
        self.pSpecularColor.pack(fill=tkinter.X, expand=0)
        self.bind(self.pSpecularColor, 'Set point light specular color')

        self.pPosition = Vector3Entry(pointPage, text='Position')
        self.pPosition['command'] = self.setPosition
        self.pPosition['resetValue'] = [0, 0, 0, 0]
        self.pPosition.pack(fill=tkinter.X, expand=0)
        self.bind(self.pPosition, 'Set point light position')

        self.pConstantAttenuation = Slider(pointPage,
                                           text='Constant Attenuation',
                                           max=1.0,
                                           resolution=0.01,
                                           value=1.0)
        self.pConstantAttenuation['command'] = self.setConstantAttenuation
        self.pConstantAttenuation.pack(fill=tkinter.X, expand=0)
        self.bind(self.pConstantAttenuation,
                  'Set point light constant attenuation')

        self.pLinearAttenuation = Slider(pointPage,
                                         text='Linear Attenuation',
                                         max=1.0,
                                         resolution=0.01,
                                         value=0.0)
        self.pLinearAttenuation['command'] = self.setLinearAttenuation
        self.pLinearAttenuation.pack(fill=tkinter.X, expand=0)
        self.bind(self.pLinearAttenuation,
                  'Set point light linear attenuation')

        self.pQuadraticAttenuation = Slider(pointPage,
                                            text='Quadratic Attenuation',
                                            max=1.0,
                                            resolution=0.01,
                                            value=0.0)
        self.pQuadraticAttenuation['command'] = self.setQuadraticAttenuation
        self.pQuadraticAttenuation.pack(fill=tkinter.X, expand=0)
        self.bind(self.pQuadraticAttenuation,
                  'Set point light quadratic attenuation')

        # Spot light controls
        self.sSpecularColor = seColorEntry(spotPage, text='Specular Color')
        self.sSpecularColor['command'] = self.setSpecularColor
        self.sSpecularColor.pack(fill=tkinter.X, expand=0)
        self.bind(self.sSpecularColor, 'Set spot light specular color')

        self.sConstantAttenuation = Slider(spotPage,
                                           text='Constant Attenuation',
                                           max=1.0,
                                           resolution=0.01,
                                           value=1.0)
        self.sConstantAttenuation['command'] = self.setConstantAttenuation
        self.sConstantAttenuation.pack(fill=tkinter.X, expand=0)
        self.bind(self.sConstantAttenuation,
                  'Set spot light constant attenuation')

        self.sLinearAttenuation = Slider(spotPage,
                                         text='Linear Attenuation',
                                         max=1.0,
                                         resolution=0.01,
                                         value=0.0)
        self.sLinearAttenuation['command'] = self.setLinearAttenuation
        self.sLinearAttenuation.pack(fill=tkinter.X, expand=0)
        self.bind(self.sLinearAttenuation, 'Set spot light linear attenuation')

        self.sQuadraticAttenuation = Slider(spotPage,
                                            text='Quadratic Attenuation',
                                            max=1.0,
                                            resolution=0.01,
                                            value=0.0)
        self.sQuadraticAttenuation['command'] = self.setQuadraticAttenuation
        self.sQuadraticAttenuation.pack(fill=tkinter.X, expand=0)
        self.bind(self.sQuadraticAttenuation,
                  'Set spot light quadratic attenuation')

        self.sExponent = Slider(spotPage,
                                text='Exponent',
                                max=1.0,
                                resolution=0.01,
                                value=0.0)
        self.sExponent['command'] = self.setExponent
        self.sExponent.pack(fill=tkinter.X, expand=0)
        self.bind(self.sExponent, 'Set spot light exponent')

        # MRM: Add frustum controls

        self.lightNotebook.setnaturalsize()
        self.lightNotebook.pack(expand=1, fill=tkinter.BOTH)

        mainFrame.pack(expand=1, fill=tkinter.BOTH)

    def onDestroy(self, event):
        messenger.send('LP_close')
        '''
        If you have open any thing, please rewrite here!
        '''
        pass

    def renameLight(self):
        #################################################################
        # renameLight(self)
        # Call Back function
        # This function will be called when user push
        # the "Rename" button on the panel.
        #
        # Then, this function will collect data and send out them with a message
        # "LP_rename"
        # Which will be caught by sceneEditor and pass to dataHolder to
        # complete the renaming.
        #
        #################################################################
        oName = self.currentLight
        nName = self.lightEntry.get()
        messenger.send('LP_rename', [oName, nName])
        return

    def deleteLight(self):
        #################################################################
        # deleteLight(self)
        # Call Back Function.
        # This function will be called when user click on
        # the "Delete" button on the panel.
        #
        # Then, this function will send out a message with current seleted light
        # "LP_removeLight"
        # Which will be caught by sceneEditor and pass to dataHolder to
        # complete the delete process.
        #
        #################################################################
        messenger.send('LP_removeLight', [self.currentLight])
        return

    def updateList(self, list, node=None):
        #################################################################
        # updataList(self, list, node = None)
        # This function will take a list object which contains names of lights in the scene.
        # Also, if user has put node as a parameter,
        # this function will automatically select that node as the current working target.
        #################################################################
        self.lightList = list
        self.lightEntry.setlist(list)
        if node != None:
            self.lightEntry.selectitem(index=node.getName(), setentry=True)
            self.updateDisplay(node)
        elif len(list) > 0:
            self.lightEntry.selectitem(index=0, setentry=True)
            self.selectLight(list[0])
        else:
            self.lightEntry.clear()
        return

    def selectLight(self, lightName):
        #################################################################
        # selectLight(self, lightName)
        # This function will be called each time when
        # user select a light from the list on the panel.
        # Then, this function will send out the message,
        # 'LP_selectLight' to sceneEditorand get the current light information from dataHolder.
        #################################################################
        if lightName in self.lightList:
            messenger.send('LP_selectLight', [lightName])
        return

    def updateDisplay(self, lightNode):
        #################################################################
        # updateDisplay(self, lightNode)
        # This function will update the information showing on the panel.
        # For example, give a lightNode which is a Point Light.
        # This function will switch the page to specify the type.
        # Also, new node is the same type with the previous one,
        # then this is function won't do the page switching,
        # but will call other function to refresh the data to target node.
        #################################################################
        self.currentLight = lightNode
        if self.currentLight != None:
            color = lightNode.getLightColor()
            self.lightColor.set(
                [255 * color.getX(), 255 * color.getY(), 255 * color.getZ()])
            oldType = self.type
            self.type = lightNode.getType()
        else:
            self.lightColor.set([255 * 0.3, 255 * 0.3, 255 * 0.3])
            oldType = self.type
            self.type = 'ambient'

        if self.type == 'ambient':
            self.lightNotebook.selectpage('Ambient')
        elif self.type == 'directional':
            self.lightNotebook.selectpage('Directional')
        elif self.type == 'point':
            self.lightNotebook.selectpage('Point')
        elif self.type == 'spot':
            self.lightNotebook.selectpage('Spot')
        if oldType == self.type:
            # The same type with previous one, call updateLightInfo to refresh the values.
            self.updateLightInfo()
        return

    def updateLightInfo(self, page=None):
        #################################################################
        # updateLightInfo(self, page=None)
        # This function will refresh the data we user have done any selection.
        #################################################################
        if self.currentLight != None:
            light = self.currentLight.getLight()
        if self.type != 'ambient':
            specColor = light.getSpecularColor()
        if self.type == 'directional':
            point = self.currentLight.getPosition()
            dir = self.currentLight.getOrientation()
            self.dSpecularColor.set([
                specColor.getX() * 255,
                specColor.getY() * 255,
                specColor.getZ() * 255
            ])
            self.dPosition.set([point.getX(), point.getY(), point.getZ()])
            self.dOrientation.set([dir.getX(), dir.getY(), dir.getZ()])
        elif self.type == 'point':
            point = self.currentLight.getPosition()
            attenuation = light.getAttenuation()
            self.pSpecularColor.set([
                specColor.getX() * 255,
                specColor.getY() * 255,
                specColor.getZ() * 255
            ])
            self.pPosition.set([point.getX(), point.getY(), point.getZ()])
            self.pConstantAttenuation.set(attenuation.getX())
            self.pLinearAttenuation.set(attenuation.getY())
            self.pQuadraticAttenuation.set(attenuation.getZ())
        elif self.type == 'spot':
            attenuation = light.getAttenuation()
            expo = light.getExponent()
            self.sSpecularColor.set([
                specColor.getX() * 255,
                specColor.getY() * 255,
                specColor.getZ() * 255
            ])
            self.sConstantAttenuation.set(attenuation.getX())
            self.sLinearAttenuation.set(attenuation.getY())
            self.sQuadraticAttenuation.set(attenuation.getZ())
            self.sExponent.set(expo)
        return

    def addAmbient(self):
        #################################################################
        # addAmbient(self)
        # This function will send out a message to
        # ask dataHolder to create a default ambient light
        #################################################################
        messenger.send('LP_addLight', ['ambient'])
        return

    def addDirectional(self):
        #################################################################
        # addDirectional(self)
        # This function will send out a message to
        # sk dataHolder to create a default Directional light
        #################################################################
        messenger.send('LP_addLight', ['directional'])
        return

    def addPoint(self):
        #################################################################
        # addPoint(self)
        # This function will send out a message to
        # ask dataHolder to create a default Point light
        #################################################################
        messenger.send('LP_addLight', ['point'])
        return

    def addSpot(self):
        #################################################################
        # addSpot(self)
        # This function will send out a message to
        # ask dataHolder to create a default Spot light
        #################################################################
        messenger.send('LP_addLight', ['spot'])
        return

    def setLightingColorVec(self, color):
        #################################################################
        # setLightingColorVec(self,color)
        # Call Back function. This will be called
        # when user try to change the color of light.
        #################################################################
        if self.currentLight == None:
            return
        self.currentLight.setColor(
            VBase4((color[0] / 255), (color[1] / 255), (color[2] / 255), 1))
        return

    def setSpecularColor(self, color):
        #################################################################
        # setSpecularColor(self,color)
        # Call Back function. This will be called
        # when user try to change the Specular color of light.
        #################################################################
        if self.currentLight == None:
            return
        self.currentLight.setSpecColor(
            VBase4((color[0] / 255), (color[1] / 255), (color[2] / 255), 1))
        return

    def setPosition(self, position):
        #################################################################
        # setPosition(self,position)
        # Call Back function. This will be called
        # when user try to change the position of light.
        #################################################################
        if self.currentLight == None:
            return
        self.currentLight.setPosition(
            Point3(position[0], position[1], position[2]))
        return

    def setOrientation(self, orient):
        #################################################################
        # setOrientation(self, orient)
        # Call Back function. This will be called
        # when user try to change the orientation of light.
        #################################################################
        if self.currentLight == None:
            return
        self.currentLight.setOrientation(Vec3(orient[0], orient[1], orient[2]))
        return

    def setConstantAttenuation(self, value):
        #################################################################
        # setConstantAttenuation(self, value)
        # Call Back function. This will be called
        # when user try to change the Constant Attenuation of light.
        #################################################################
        self.currentLight.setConstantAttenuation(value)
        return

    def setLinearAttenuation(self, value):
        #################################################################
        # setLinearAttenuation(self, value)
        # Call Back function. This will be called
        # when user try to change the Linear Attenuation of light.
        #################################################################
        self.currentLight.setLinearAttenuation(value)
        return

    def setQuadraticAttenuation(self, value):
        #################################################################
        # setQuadraticAttenuation(self, value)
        # Call Back function. This will be called
        # when user try to change the Quadratic Attenuation of light.
        #################################################################
        self.currentLight.setQuadraticAttenuation(value)
        return

    def setExponent(self, value):
        #################################################################
        # setExponent(self, value)
        # Call Back function. This will be called
        # when user try to change Exponent value of light.
        #################################################################
        self.currentLight.setExponent(value)
        return
Esempio n. 13
0
from tkinter import (
    Tk, Menubutton, RAISED, Menu, IntVar
)

layar = Tk()
layar.title("Menu Button")
layar.geometry("300x100")

mb = Menubutton( master=layar, text="condiment", relief=RAISED)
mb.grid()
mb.menu = Menu( master=mb, tearoff=0)

mb["menu"] = mb.menu

mayoVar = IntVar()
ketchVar = IntVar()

mb.menu.add_checkbutton(label="mayo", variable=mayoVar)
mb.menu.add_checkbutton(label="ketch", variable=ketchVar)

mb.pack()

layar.mainloop()
Esempio n. 14
0
File: tkui.py Progetto: mindhog/mawb
    def __init__(self, client):
        Tk.__init__(self)
        self.client = client
        self.programPanel = ProgramPanel(client)
        self.programPanel.grid(row = 0, column = 0, sticky = NSEW)

        self.frame = Frame(self)
        self.frame.grid(row = 0, column = 0, sticky = NSEW)
        nextRow = Counter()

        # Create the menu.
        menu = Frame(self.frame)
        addButton = Menubutton(menu, text = 'Add')
        addButton.pack()
        menu.grid(row = nextRow(), column = 0, sticky = W)

        # Create the program panel.
        self.program = ProgramWidget(self.frame, client)
        self.program.grid(row = nextRow(), column = 0, columnspan = 2,
                          sticky = W)

        label = Label(self.frame, text = 'AWB')
        label.grid(row = nextRow(), column = 0)

        self.recordMode = Button(self.frame, text = 'P',
                                 command = self.toggleRecord)
        modeRow = nextRow()
        self.recordMode.grid(row = modeRow, column = 0, sticky = W)
        self.status = Label(self.frame, text = 'Idle')
        self.status.grid(row = modeRow, column = 1)

        self.channels = []
        self.channelFrame = Frame(self.frame)
        self.channelFrame.grid(row = nextRow(), columnspan = 2)

        self.bind('q', self.terminate)
        self.bind('f', self.foo)

        self.bind('r', self.toggleRecord)
        self.bind('k', self.toggleSticky)
        self.bind('.', self.nextSection)
        self.bind(',', self.prevSection)
        self.bind('<space>', self.togglePause)
        self.bind('K', self.clearAllState)
        self.protocol('WM_DELETE_WINDOW', self.destroy)

        self.bind('<F1>', lambda evt: self.frame.tkraise())
        self.bind('<F2>', lambda evt: self.programPanel.tkraise())

        for i in range(0, 8):

            # Bind number key.
            self.bind(str(i),
                      lambda evt, channel = i: self.toggleChannel(channel)
                      )

            # Create channel
            channel = Channel(self.channelFrame, i)
            self.channels.append(channel)
            channel.pack(side = LEFT)

            client.addChannelSubscriber(
                i,
                lambda ch, status, channel = channel:
                    channel.changeStatus(status)
            )
Esempio n. 15
0
quit_tk = Button(top,
                 text="QUIT",
                 command=top.quit,
                 activeforeground='white',
                 activebackground='red')
quit_tk.pack()

mb_lang = Menubutton(top, text='Language')

mb_lang.menu = Menu(mb_lang)
# 生成菜单项
for item in ['Python', 'PHP', 'CPP', 'C', 'Java', 'JavaScript', 'VBScript']:
    mb_lang.menu.add_command(label=item)
mb_lang['menu'] = mb_lang.menu
mb_lang.pack(side=LEFT)

# 添加向菜单中添加checkbutton项
mb_os = Menubutton(top, text='OS')
mb_os.menu = Menu(mb_os)
for item in ['Unix', 'Linux', 'Soloris', 'Windows']:
    mb_os.menu.add_checkbutton(label=item)
mb_os['menu'] = mb_os.menu
mb_os.pack(side=LEFT)

# 向菜单中添加radiobutton项
mb_linux = Menubutton(top, text='Linux')
mb_linux.menu = Menu(mb_linux)
for item in ['Redhat', 'Fedra', 'Suse', 'ubuntu', 'Debian']:
    mb_linux.menu.add_radiobutton(label=item)
mb_linux['menu'] = mb_linux.menu
Esempio n. 16
0
    def __init__(self, regexs):
        """
        The regexs to use in this session
        :param regexs: A dictionary as described in settings.py
        """
        global regexscolours
        global win
        # Create the colors for the regexs
        regexscolours = {}
        for regex in regexs:
            ct = [random.randrange(256) for x in range(3)]
            brightness = int(round(0.299 * ct[0] + 0.587 * ct[1] + 0.114 * ct[2]))
            ct_hex = "%02x%02x%02x" % tuple(ct)
            bg_colour = '#' + "".join(ct_hex)
            fg = 'White' if brightness < 120 else 'Black'  # If brightness is too high foreground will be black
            regexscolours[regex] = (bg_colour, fg)
        # Create the main window
        self.win = win = tk.Tk()
        self.win.geometry("1600x800+50+50")
        self.win.title("LogVisualizer")
        self.tabframe = tk.Frame(win)
        self.bottom_frame = tk.Frame(win)
        self.tabsection = TabSelector(self)
        # Draw the menubar
        menu_bar = tk.Menu(win, tearoff=0)
        win.config(menu=menu_bar)
        # Add a cascade for the file managing
        file_cascade = tk.Menu(menu_bar, tearoff=0)
        file_cascade.add_command(label="Open file", command=self.promptlocalfileloader)
        file_cascade.add_command(label="Open remote file", command=self.promptremotefileloader)
        file_cascade.add_separator()
        file_cascade.add_command(label="Quit", command=win.destroy)

        menu_bar.add_cascade(label="File", menu=file_cascade)

        # Draw the filters and tab control on the left side of the window
        self.leftframe = tk.Frame(win)
        addbutton = tk.Button(self.leftframe, text="Add", padx=8, command=lambda: self.tabsection.addtab("Empty"))
        erasebutton = tk.Button(self.leftframe, text="Del", padx=8, command=lambda: self.tabsection.erasetab())
        self.leftframe.pack(side=tk.LEFT)
        addbutton.grid(row=1, column=0)
        erasebutton.grid(row=1, column=1)
        todraw = []
        cascades = []
        buttons = []
        self.filter_menu_frame = tk.Frame(self.leftframe, relief=tk.RAISED, bd=2)
        self.filter_menu_frame.grid(row=2, columnspan=2, ipady=220, ipadx=21)

        filter_menu = Menubutton(self.filter_menu_frame, text="Filters")
        topmenu = tk.Menu(filter_menu, tearoff=True)
        filter_menu.configure(menu=topmenu)

        for path in regexs:
            for submenu in range(len(path.split("_"))):
                todraw.append("_".join(path.split("_")[:submenu+1]))
        todraw = list(dict.fromkeys(todraw).keys())
        todraw.remove("")
        # Separate cascades from final buttons
        for element in todraw:
            if "·" in element:
                buttons.append(element)
                cascades.append("_".join(element.split("·")[:-1]))
            else:
                cascades.append(element)
        cascades = list(dict.fromkeys(cascades).keys())
        cascades.sort()
        # Draw submenus with cascades
        for cascade in cascades:
            splitted = cascade.split("_")
            if len(splitted) == 2:
                exec("_" + splitted[-1] + " = tk.Menu(topmenu)")
                exec("topmenu.add_cascade(label=splitted[-1], menu=" + "_" + splitted[-1] + ")")
            else:
                parent = "_".join(splitted[:-1])
                actual = "_".join(splitted)
                exec(actual + " =  tk.Menu(" + parent + ")")
                exec(parent + ".add_cascade(label=splitted[-1], menu=" + actual + ")")

        i = 0 # Auxiliary variable
        for filter in buttons:
            splitted = filter.split("·")
            parent = splitted[0]
            filtername = splitted[1]
            exec(parent + ".add_command(label = filtername, command = lambda self=self: alternateregex(self, %s))" % i)
            i = i + 1

        filter_menu.pack(expand=tk.YES, fill=tk.BOTH)
        self.tabframe.pack(expand=tk.YES, fill=tk.BOTH)

        bottom_frame = tk.Frame(win)
        bottom_frame.pack(side=tk.BOTTOM)
        self.tabsection.addtab("Empty")