Bind mouse wheel to Spinboxes
This commit is contained in:
@@ -6,9 +6,15 @@ import random
|
||||
from CLI import parse_arguments, get_working_dirs
|
||||
from Main import main
|
||||
from Utils import local_path, output_path, open_file
|
||||
import gui.widgets as widgets
|
||||
|
||||
def bottom_frame(self,parent,args=None):
|
||||
# Bottom Frame
|
||||
self = ttk.Frame(parent)
|
||||
|
||||
# Bottom Frame options
|
||||
self.bottomWidgets = {}
|
||||
|
||||
seedCountFrame = Frame(self)
|
||||
seedCountFrame.pack()
|
||||
## Seed #
|
||||
@@ -22,19 +28,25 @@ def bottom_frame(self,parent,args=None):
|
||||
seedEntry = Entry(self, width=15, textvariable=self.seedVar)
|
||||
seedLabel.pack(side=LEFT)
|
||||
seedEntry.pack(side=LEFT)
|
||||
|
||||
## Number of Generation attempts
|
||||
countLabel = Label(self, text='Count')
|
||||
self.countVar = StringVar(value=parent.working_dirs["gen.count"])
|
||||
countSpinbox = Spinbox(self, from_=1, to=100, width=5, textvariable=self.countVar)
|
||||
countLabel.pack(side=LEFT)
|
||||
countSpinbox.pack(side=LEFT)
|
||||
key = "generationcount"
|
||||
self.bottomWidgets[key] = widgets.make_widget(
|
||||
self,
|
||||
"spinbox",
|
||||
self,
|
||||
"Count",
|
||||
None,
|
||||
{"label": {"side": LEFT}, "spinbox": {"side": RIGHT}}
|
||||
)
|
||||
self.bottomWidgets[key].pack(side=LEFT)
|
||||
|
||||
def generateRom():
|
||||
guiargs = Namespace()
|
||||
guiargs.multi = int(parent.multiworldWindow.multiworldWidgets["worlds"].storageVar.get())
|
||||
guiargs.names = parent.multiworldWindow.namesVar.get()
|
||||
guiargs.seed = int(parent.farBottomFrame.seedVar.get()) if parent.farBottomFrame.seedVar.get() else None
|
||||
guiargs.count = int(parent.farBottomFrame.countVar.get()) if parent.farBottomFrame.countVar.get() != '1' else None
|
||||
guiargs.count = int(parent.farBottomFrame.bottomWidgets["generationcount"].storageVar.get()) if parent.farBottomFrame.bottomWidgets["generationcount"].storageVar.get() != '1' else None
|
||||
guiargs.mode = parent.itemWindow.itemWidgets["worldstate"].storageVar.get()
|
||||
guiargs.logic = parent.itemWindow.itemWidgets["logiclevel"].storageVar.get()
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ def loadcliargs(gui,args):
|
||||
if args.multi:
|
||||
gui.multiworldWindow.multiworldWidgets["worlds"].storageVar.set(str(args.multi))
|
||||
if args.count:
|
||||
gui.farBottomFrame.countVar.set(str(args.count))
|
||||
gui.farBottomFrame.bottomWidgets["generationcount"].storageVar.set(str(args.count))
|
||||
if args.seed:
|
||||
gui.farBottomFrame.seedVar.set(str(args.seed))
|
||||
gui.itemWindow.itemWidgets["worldstate"].storageVar.set(args.mode)
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
from tkinter import Checkbutton, Entry, Frame, IntVar, Label, OptionMenu, Spinbox, StringVar, RIGHT
|
||||
|
||||
class mySpinbox(Spinbox):
|
||||
def __init__(self, *args, **kwargs):
|
||||
Spinbox.__init__(self, *args, **kwargs)
|
||||
self.bind('<MouseWheel>', self.mouseWheel)
|
||||
self.bind('<Button-4>', self.mouseWheel)
|
||||
self.bind('<Button-5>', self.mouseWheel)
|
||||
|
||||
def mouseWheel(self, event):
|
||||
if event.num == 5 or event.delta == -120:
|
||||
self.invoke('buttondown')
|
||||
elif event.num == 4 or event.delta == 120:
|
||||
self.invoke('buttonup')
|
||||
|
||||
def make_checkbox(self, parent, label, storageVar, packAttrs):
|
||||
self = Frame(parent)
|
||||
self.storageVar = storageVar
|
||||
@@ -41,7 +54,7 @@ def make_spinbox(self, parent, label, storageVar, packAttrs):
|
||||
fromNum = packAttrs["spinbox"]["from"]
|
||||
if "to" in packAttrs:
|
||||
toNum = packAttrs["spinbox"]["to"]
|
||||
self.spinbox = Spinbox(self, from_=fromNum, to=toNum, width=5, textvariable=self.storageVar)
|
||||
self.spinbox = mySpinbox(self, from_=fromNum, to=toNum, width=5, textvariable=self.storageVar)
|
||||
self.spinbox.pack(packAttrs["spinbox"])
|
||||
return self
|
||||
|
||||
|
||||
Reference in New Issue
Block a user