コード例 #1
0
    def test_FrameListView(self):
        win = tk.Tk()
        constructor = TestFrame
        args = ("1", "2", "3")
        view = FrameListView(win)
        view.Load(constructor, args, "X")
        view.pack(anchor='n', fill=tk.BOTH, expand=True, side='left')

        #tk.mainloop()
        win.destroy()
コード例 #2
0
    def test_FrameListViewSelectMode(self):
        win = tk.Tk()
        constructor = TestFrame
        args = ("1", "2", "3")
        view = FrameListView(win, selectMode = True)
        view.Load(constructor, args, "X")
        view.pack(anchor='n', fill=tk.BOTH, expand=True, side='left')

        #tk.mainloop()
        result = [p.Text.get() for p in view.GetSelected()]
        print(result)
        win.destroy()
コード例 #3
0
 def test_FrameListViewMoves(self):
     win = tk.Tk()
     constructor = TestFrame
     args = ("1", "2", "3")
     view = FrameListView(win)
     view.Load(constructor, args, "X")
     view.pack(anchor='n', fill=tk.BOTH, expand=True, side='left')
     view.Insert(2, FrameListViewItem(view, TestFrame, "A"))
     view.Insert(3, FrameListViewItem(view, TestFrame, "B"))
     view.Insert(4, FrameListViewItem(view, TestFrame, "C"))
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['1', '2', 'A', 'B', 'C', '3']
     self.assertEqual(str(actual), str(expected), "Insert of items mid list failed")
     view.MovingObject = view.Items[2]
     view.MoveOrCreate(view.Items[0])
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['A', '1', '2', 'B', 'C', '3']
     self.assertEqual(str(actual), str(expected), "Move of item to start of list failed")
     view.MovingObject = view.Items[0]
     view.MoveOrCreate(view.Items[5])
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['1', '2', 'B', 'C', 'A', '3']
     self.assertEqual(str(actual), str(expected), "Move of item to before end of list failed")
     view.MovingObject = view.Items[4]
     view.MoveOrCreate(view.Items[5], True)
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['1', '2', 'B', 'C', '3', 'A']
     self.assertEqual(str(actual), str(expected), "Move of item to end of list failed")
     view.MovingObject = view.Items[-1]
     view.MoveOrCreate(view.Items[4])
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['1', '2', 'B', 'C', 'A', '3']
     self.assertEqual(str(actual), str(expected), "Move of item to middle of list failed")
     view.MovingObject = None
     view.MoveOrCreate(view.Items[-1], True)
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['1', '2', 'B', 'C', 'A', '3', 'X']
     self.assertEqual(str(actual), str(expected), "Add of item to end of list failed")
     view.Remove(view.Items[-1])
     view.Remove(view.Items[4])
     view.Remove(view.Items[3])
     view.Remove(view.Items[2])
     actual = [item.Item.Text.get() for item in view.Items]
     expected = ['1', '2', '3']
     self.assertEqual(str(actual), str(expected), "Removing items failed")
     win.destroy()
コード例 #4
0
    def __init__(self, parent, macro: Macro):
        KeystoneFrame.__init__(self, parent)

        #StringVar for Name
        self.Name = ""

        #List of commands view frame
        self.Commands = None

        #layout grid
        self.columnconfigure(0, weight=1, minsize=200)
        self.columnconfigure(1, weight=0)
        self.columnconfigure(2, weight=7)
        self.rowconfigure(0, weight=1)

        #add controls
        
        self.NameFrame = KeystoneFrame(self)
        self.NameFrame.columnconfigure(1, weight=1)
        self.NameFrame.columnconfigure(2, weight=0)
        self.NameFrame.rowconfigure(4, weight=1)
        self.NameFrame.grid(row=0, column=0, sticky='nsew') 

        self.CommandsFrame=KeystoneFrame(self)
        self.CommandsFrame.columnconfigure(0, weight=1)
        self.CommandsFrame.grid(row=0, column=2, sticky='nsew', padx="3", pady="3")
        
        self.Commands = FrameListView(self.CommandsFrame)
        self.Commands.grid(row=0, column=0, sticky='new')

        nameLabel = KeystoneLabel(self.NameFrame, anchor='nw', text="Name", width=5)
        nameLabel.grid(row=1, column=0, sticky="nw", padx="3", pady="3")
        self.Name = tk.StringVar()
        self.NameBox = KeystoneEntry(self.NameFrame, textvariable=self.Name)
        self.NameBox.grid(row=1, column=1, sticky="nsew", padx="3", pady="3")

        self.CommandOnly = tk.BooleanVar(value=False)
        self.CommandOnlyCheck = KeystoneCheckbutton(self.NameFrame, variable=self.CommandOnly)
        self.CommandOnlyCheck.grid(row=2, column=0, sticky="ne", padx="3", pady="3")
        commandOnlyLabel = KeystoneLabel(self.NameFrame, anchor='nw', text='Copy command only')
        commandOnlyLabel.grid(row=2, column=1, sticky="nw", padx="3", pady="3")
        
        self.Load(macro)
コード例 #5
0
    def __init__(self,
                 parent,
                 bindFile: BindFile = None,
                 list=False,
                 showUploadBindButton=False,
                 onSaveCallback=None,
                 onSelectCallback=None):
        KeystoneEditFrame.__init__(self, parent)

        self.OnSetDirty.append(self.ShowSaveButtons)
        self.OnSetClean.append(self.HideSaveButtons)

        self.SaveButton = None

        self.CancelButton = None

        self.SelectMode = False
        self.OnSelectCallback = onSelectCallback

        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=0)
        self.columnconfigure(2, weight=0)
        self.columnconfigure(3, weight=0)
        self.columnconfigure(4, weight=0)
        self.columnconfigure(5, weight=0)
        self.rowconfigure(0, weight=0)
        self.rowconfigure(1, weight=1)

        self.PathLabel = KeystoneLabel(self)
        self.PathLabel.grid(row=0, column=0, sticky='nsew')

        self.SaveButton = KeystoneButton(self,
                                         text="Save",
                                         command=self.OnSave)
        self.SaveButton.Color("green", "black")

        self.CancelButton = KeystoneButton(self,
                                           text="Cancel",
                                           command=self.OnCancel)
        self.CancelButton.Color("red", "black")

        self.NewBindButton = KeystoneButton(self,
                                            text="New Bind",
                                            command=self.OnNewBind)
        self.NewBindButton.Color("yellow", "black")
        self.NewBindButton.grid(row=0, column=3, sticky='nse')

        self.OkSelectButton = KeystoneButton(self,
                                             text="Select",
                                             command=self.OnOkSelect)
        self.OkSelectButton.Color("green", "black")

        self.CancelSelectButton = KeystoneButton(self,
                                                 text="Cancel",
                                                 command=self.OnCancelSelect)
        self.CancelSelectButton.Color("red", "black")

        if (showUploadBindButton):
            self.UploadBindButton = KeystoneButton(self,
                                                   text="Add Upload Bind",
                                                   command=self.AddUploadBind)
            self.UploadBindButton.Color("orange", "black")
            self.UploadBindButton.grid(row=0, column=4, sticky='nse')

        scrollingFrame = ScrollingFrame(self)
        scrollingFrame.grid(row=1, column=0, columnspan=5, sticky='nsew')

        self.view = FrameListView(scrollingFrame.scrollwindow,
                                  showControlsOnFocus=(list))
        self.view.pack(fill=tk.BOTH, expand=1)
        self.view.OnSetDirty.append(self.SetDirty)

        self.List = tk.BooleanVar()
        self.List.set(list)

        self.Editor = None

        self.OnSaveCallback = onSaveCallback

        self.FilePath = None
        self.LoadedFile = None

        if (bindFile != None):
            self.Load(bindFile)
コード例 #6
0
    def __init__(self, parent, bind: Bind, lockKey=False, dirty=False):
        KeystoneEditFrame.__init__(self, parent)

        #StringVar for Key
        self.Key = None

        #StringVar for Chord
        self.Chord = None

        #StringVar for Key Description
        self.KeyDescription = None

        #StringVar for Chord Description
        self.ChordDescription = None

        #List of commands view frame
        self.Commands = None

        #Indicates keys cannot be edited
        self._lockKey = lockKey

        #layout grid
        self.columnconfigure(0, weight=1, minsize=200)
        self.columnconfigure(1, weight=0)
        self.columnconfigure(2, weight=7)
        self.rowconfigure(0, weight=1)

        #add controls

        self.KeyFrame = KeystoneFrame(self)
        self.KeyFrame.columnconfigure(1, weight=1)
        self.KeyFrame.columnconfigure(2, weight=0)
        self.KeyFrame.rowconfigure(4, weight=1)

        self.CommandsFrame = KeystoneFrame(self)
        self.CommandsFrame.columnconfigure(0, weight=1)

        self.Commands = FrameListView(self.CommandsFrame)
        self.Commands.OnSetDirty.append(self.SetDirty)
        self.Commands.grid(row=0, column=0, sticky='new')

        self.TextFrame = KeystoneFrame(self)
        self.TextFrame.rowconfigure(0, weight=1, minsize='55')
        self.TextFrame.columnconfigure(0, weight=1, minsize='405')

        self.Delete = tk.Button(self,
                                text=self.DELETE_TEXT,
                                background=self.DELETE_COLOR,
                                foreground=self.DELETE_TEXT_COLOR,
                                font=(TEXT_FONT, 7, "bold"),
                                relief=self.DELETE_STYLE,
                                width=1,
                                wraplength=1,
                                command=self.OnDelete)

        self.Assign = tk.Button(self,
                                text=self.ASSIGN_TEXT,
                                background=self.ASSIGN_COLOR,
                                foreground=self.ASSIGN_TEXT_COLOR,
                                font=(TEXT_FONT, 7, "bold"),
                                relief=self.DELETE_STYLE,
                                width=1,
                                wraplength=1,
                                command=self.AssignCommand)

        self.UIToTextButton = KeystoneButton(self,
                                             text="Edit As Text",
                                             command=self.SynchUIToText)

        keyLabel = KeystoneLabel(self.KeyFrame,
                                 anchor='nw',
                                 text="Key",
                                 width=5)
        keyLabel.grid(row=1, column=0, sticky="nw", padx="3", pady="3")
        self.Key = tk.StringVar()
        self.KeyValue = KeystoneLabel(self.KeyFrame,
                                      anchor='nw',
                                      textvariable=self.Key,
                                      width=5)
        self.KeyBox = KeystoneKeyCombo(self.KeyFrame,
                                       textvariable=self.Key,
                                       values=" ".join(
                                           [c[0] for c in KEY_NAMES]))
        self.Key.trace("w", self.SelectKey)

        self.KeyDescription = tk.StringVar()
        keyDescription = KeystoneLabel(self.KeyFrame,
                                       anchor="nw",
                                       textvariable=self.KeyDescription,
                                       wraplength=200)
        keyDescription.grid(row=2,
                            column=0,
                            columnspan=2,
                            sticky="nsew",
                            padx="3",
                            pady="3")

        self.Key.set(bind.Key)
        self.Key.trace("w", self.SetDirty)

        chordLabel = KeystoneLabel(self.KeyFrame,
                                   anchor='nw',
                                   text="Chord",
                                   width=5)
        chordLabel.grid(row=3, column=0, sticky="nw", padx="3", pady="3")
        self.Chord = tk.StringVar()
        self.ChordValue = KeystoneLabel(self.KeyFrame,
                                        anchor='nw',
                                        textvariable=self.Chord,
                                        width=5)
        self.ChordBox = KeystoneKeyCombo(self.KeyFrame,
                                         textvariable=self.Chord,
                                         values=" ".join(
                                             [c[0] for c in CHORD_KEYS]))
        self.Chord.trace("w", self.SelectChord)

        self.ChordDescription = tk.StringVar()
        chordDescription = KeystoneLabel(self.KeyFrame,
                                         anchor="nw",
                                         textvariable=self.ChordDescription,
                                         wraplength=200)
        chordDescription.grid(row=4,
                              column=0,
                              columnspan=2,
                              sticky="nsew",
                              padx="3",
                              pady="3")

        self.Chord.set(bind.Chord)
        self.Chord.trace("w", self.SetDirty)

        self.UnlockKeysButton = KeystoneButton(self,
                                               text="Change Assigned Key",
                                               command=self.UnlockKeys)
        self.UnlockKeysButton.Color(FOREGROUND, BACKGROUND)

        self.ShowCommands = tk.BooleanVar()
        self.ShowCommands.trace("w", self.OnShowCommands)

        self.TextEntry = KeystoneTextEntry(self.TextFrame, height=5)
        self.TextEntry.grid(row=0, column=0, sticky="nsew", padx="3", pady="3")
        self.TextEntry.bind("<Key>", self.SetDirty)

        self.ShowTextEditor = tk.BooleanVar()
        self.ShowTextEditor.set(False)
        self.ShowTextEditor.trace("w", self.OnShowTextEditor)

        self.TextToUIButton = KeystoneButton(self.TextFrame,
                                             text="Editor",
                                             command=self.SynchTextToUI)
        self.TextToUIButton.grid(row=1,
                                 column=0,
                                 sticky="nsew",
                                 padx="3",
                                 pady="3")

        self.OnShowTextEditor()
        self.UnlockKeys(not lockKey)

        self.Load(bind)
        self.Dirty.set(dirty)