def __init__(self, parent, link: Keylink, keychain: Keychain): KeystoneEditFrame.__init__(self, parent) self.Keychain = keychain self.RootPath = os.path.dirname(keychain.RootPath) if (link == None): #new link filePath = self.Keychain.GetNewFileName() self.Link = keychain.Newlink(filePath) else: self.Link = link #layout grid and frames self.columnconfigure(0, weight=0) self.columnconfigure(1, weight=1) self.rowconfigure(0, weight=0) self.FileName = tk.StringVar() self.NameEdit = KeystoneEntry(self, textvariable=self.FileName) self.NameLabel = KeystoneLabel(self, textvariable=self.FileName) name = GetDirPathFromRoot(self.RootPath, self.Link.FilePath) self.FileName.set(name) self.FileName.trace("w", self.OnSetDirty) self.NameLabel.grid(row=0, column=1, sticky='nsew') self.Button = KeystoneButton(self, text="...", width=3, command=self.OnEdit) self.Button.grid(row=0, column=0, sticky="nsew") self.Editing = False
def __init__(self, parent, message): KeystoneEditFrame.__init__(self, parent) self.Text = tk.StringVar() self.Text.set(message) self.Edit = ttk.Entry(self, textvariable=self.Text) self.Text.trace("w", self.SetDirty) self.Edit.pack(fill=tk.BOTH, expand=1)
def __init__(self, parent, saveCallback=None): KeystoneEditFrame.__init__(self, parent) self.lastItem = None self.editor = None self.selectedItem = None self.EditedItems = None self.SaveCallback = saveCallback self.Pane = KeystonePanedWindow(self, orient=tk.HORIZONTAL) self.Pane.pack(fill=tk.BOTH, expand=1) self.viewFrame = BindFileCollectionView(self.Pane) self.viewFrame.Tree.OnSelect.append(self.selectItem) self.Pane.add(self.viewFrame) self.editFrame = KeystoneFrame(self.Pane, style='editStyle.TFrame', width=1000) self.editFrame.columnconfigure(0, weight=1) self.editFrame.rowconfigure(0, weight=1) self.Pane.add(self.editFrame) self._showingTree = None self.ShowTree = tk.BooleanVar(value=False) self.ShowTree.trace("w", self.OnShowTree) self.Reset()
def __init__(self, parent, bind: Bind, dirty=False): KeystoneEditFrame.__init__(self, parent) self.BindFileEditor = parent while (self.BindFileEditor.__class__.__name__ != "EditBindFile"): self.BindFileEditor = self.BindFileEditor.master if (self.BindFileEditor == None): break self.Editor = None self.columnconfigure(0, weight=0) self.columnconfigure(1, weight=1) self.rowconfigure(0, weight=0) self.rowconfigure(1, weight=0) self._showingEdit = True self.Button = KeystoneButton(self, text="...", width=6, command=self.OnEdit) self.Button.grid(row=0, column=0, sticky="nsew") self.Repr = tk.StringVar() self.Label = KeystoneLabel(self, textvariable=self.Repr) self.Repr.set(bind.__repr__()) self.Label.grid(row=0, column=1, sticky="nsew") self.OnSetDirty.append(self.SetEdited) self.OnSetClean.append(self.SetEdited) self.BindFileEditor.OnSetClean.append(self.SetClean) if (dirty): self.SetDirty()
def __init__(self, parent, showControls=False, showControlsOnFocus=True, selectMode=False): KeystoneEditFrame.__init__(self, parent) self.MovingObject = None self.Items = None self.Constructor = None self.DefaultArgs = None self.columnconfigure(0, weight=0) self.columnconfigure(0, weight=0) self.columnconfigure(2, weight=1) self.rowconfigure(0, weight=1) #control were items are inserted self.RootItemRow = 1 self.ItemColumn = 2 #setup show controls vars self.ShowControls = tk.BooleanVar() self.ShowControls.set(showControls) self.ShowControls.trace("w", self.OnShowControls) self.ShowControlsOnFocus = tk.BooleanVar() self.ShowControlsOnFocus.set(showControlsOnFocus) self.SelectMode = tk.BooleanVar() self.SelectMode.set(selectMode) self.SelectMode.trace("w", self.OnSelectMode) self.SelectAll = KeystoneButton(self, text="Select All", command=self.OnSelectAll) self.DeselectAll = KeystoneButton(self, text="Deselect All", command=self.OnDeselectAll)
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)
def __init__(self, parent, command: SlashCommand): KeystoneEditFrame.__init__(self, parent) #Frame for formatting controls self.FormatFrame = None #Frame for decscription self.DescriptionFrame = None #StringVar for command name self.CommandName = None #text entry object self.TextEntry = None #color entry objects self.ColorEntry = None self.BackgroundEntry = None self.BorderEntry = None #StringVar for transparency self.TransparencyEntryText = None #StringVar for scale self.ScaleEntryText = None #StringVar for repeat selection self.RepeatText = None #StringVar for duration self.DurationText = None #StringVar for power description text self.DescriptionText = None #The text prompt for the last selected command, e.g. "power" for powexec_name self.TextPrompt = None #layout grid and frames self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=0) self.rowconfigure(1, weight=0) self.rowconfigure(2, weight=1) commandFrame = KeystoneFrame(self) commandFrame.grid(row=0, column=0, sticky='nsew') commandFrame.columnconfigure(0, weight=0) commandFrame.columnconfigure(1, weight=1) commandFrame.columnconfigure(2, weight=0) commandFrame.columnconfigure(3, weight=0) self.FormatFrame = formatFrame = KeystoneFrame(self) self.DescriptionFrame = descriptionFrame = KeystoneFrame(self) #add controls self.CommandName = tk.StringVar() commandBox = KeystoneCombo(commandFrame, textvariable=self.CommandName, values=" ".join([ c[0] for c in LIST_OF_SLASH_COMMANDS]), postcommand=self.LockShowFormat) commandBox.grid(row=0, column=0, sticky="w", padx="3", pady="3") self.CommandName.trace("w", self.SelectCommand) self.CommandName.trace("w", self.SetDirty) self.TextEntry = KeystoneTextEntry(commandFrame) self.TextEntry.grid(row=0, column=1, sticky="nsew", padx="3", pady="3") self.TextEntry.bind("<Key>", self.SetDirty) self.BrowseButton = KeystoneButton(commandFrame, text=" ... ", command=self.OnBrowseButton) self.NewButton = KeystoneButton(commandFrame, text="New", command=self.OnNewButton) self.IsLoadFileCommand = tk.BooleanVar() self.IsLoadFileCommand.set(False) self.IsLoadFileCommand.trace("w", self.OnSetIsLoadFileCommand) label = KeystoneLabel(formatFrame, text="Repeat Mode", anchor='n') label.grid(row=0, column=0, pady="3") repeatModes = [("Once", ""), ("Repeat [%s]" % REPEAT_STR, REPEAT_STR), ("Toggle [%s]" %TOGGLE_STR , TOGGLE_STR)] self.RepeatText = tk.StringVar() for idx, (text, mode) in enumerate(repeatModes): b = KeystoneRadio(formatFrame, text=text, value=mode, variable=self.RepeatText) b.grid(row=1+idx, column=0, sticky='w') self.RepeatText.set("") self.RepeatText.trace("w", self.SetDirty) editLabels = ["Text Color", "Background Color", "Transparency", "Border Color", "Scale", "Duration"] for idx, text in enumerate(editLabels): label = KeystoneLabel(formatFrame, text=text, anchor='n', width=30) if (idx < 3): row = 1 else: row = 3 label.grid(row=row, column=1+(idx % 3)) self.ColorEntry = ColorPicker(formatFrame) self.ColorEntry.Combo.configure(postcommand=self.LockShowFormat) self.ColorEntry.grid(row=0, column=1, padx="3", pady="3") self.ColorEntry.ColorEntryText.trace("w", self.FormatText) self.BackgroundEntry = ColorPicker(formatFrame) self.BackgroundEntry.Combo.configure(postcommand=self.LockShowFormat) self.BackgroundEntry.grid(row=0, column=2, padx="3", pady="3") self.BackgroundEntry.ColorEntryText.trace("w", self.FormatText) self.TransparencyEntryText = tk.StringVar() self.TransparencyEntry = KeystoneCombo(formatFrame, textvariable=self.TransparencyEntryText, values=" ".join([str(p) for p in range(0,101)]), width=3, postcommand=self.LockShowFormat) self.TransparencyEntry.grid(row=0, column=3) self.TransparencyEntryText.trace("w", self.FormatText) self.BorderEntry = ColorPicker(formatFrame) self.BorderEntry.Combo.configure(postcommand=self.LockShowFormat) self.BorderEntry.grid(row=2, column=1, padx="3", pady="3") self.BorderEntry.ColorEntryText.trace("w", self.FormatText) self.ScaleEntryText = tk.StringVar() scaleEntry = KeystoneEntry(formatFrame, textvariable=self.ScaleEntryText, width=5) scaleEntry.grid(row=2, column=2) self.ScaleEntryText.trace("w", self.FormatText) self.DurationText = tk.StringVar() durationEntry = KeystoneEntry(formatFrame, textvariable=self.DurationText, width=5) durationEntry.grid(row=2, column=3) self.DurationText.trace("w", self.FormatText) self.DescriptionText = tk.StringVar() description = KeystoneLabel(descriptionFrame, anchor="nw", textvariable=self.DescriptionText, wraplength=800) description.grid(sticky="nsew", padx="3", pady="3") #load model self.Load(command) #bind to hide format and desc self.BindWidgetToShowFormat(self)
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)