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 CLI import parse_arguments, get_working_dirs
|
||||||
from Main import main
|
from Main import main
|
||||||
from Utils import local_path, output_path, open_file
|
from Utils import local_path, output_path, open_file
|
||||||
|
import gui.widgets as widgets
|
||||||
|
|
||||||
def bottom_frame(self,parent,args=None):
|
def bottom_frame(self,parent,args=None):
|
||||||
|
# Bottom Frame
|
||||||
self = ttk.Frame(parent)
|
self = ttk.Frame(parent)
|
||||||
|
|
||||||
|
# Bottom Frame options
|
||||||
|
self.bottomWidgets = {}
|
||||||
|
|
||||||
seedCountFrame = Frame(self)
|
seedCountFrame = Frame(self)
|
||||||
seedCountFrame.pack()
|
seedCountFrame.pack()
|
||||||
## Seed #
|
## Seed #
|
||||||
@@ -22,19 +28,25 @@ def bottom_frame(self,parent,args=None):
|
|||||||
seedEntry = Entry(self, width=15, textvariable=self.seedVar)
|
seedEntry = Entry(self, width=15, textvariable=self.seedVar)
|
||||||
seedLabel.pack(side=LEFT)
|
seedLabel.pack(side=LEFT)
|
||||||
seedEntry.pack(side=LEFT)
|
seedEntry.pack(side=LEFT)
|
||||||
|
|
||||||
## Number of Generation attempts
|
## Number of Generation attempts
|
||||||
countLabel = Label(self, text='Count')
|
key = "generationcount"
|
||||||
self.countVar = StringVar(value=parent.working_dirs["gen.count"])
|
self.bottomWidgets[key] = widgets.make_widget(
|
||||||
countSpinbox = Spinbox(self, from_=1, to=100, width=5, textvariable=self.countVar)
|
self,
|
||||||
countLabel.pack(side=LEFT)
|
"spinbox",
|
||||||
countSpinbox.pack(side=LEFT)
|
self,
|
||||||
|
"Count",
|
||||||
|
None,
|
||||||
|
{"label": {"side": LEFT}, "spinbox": {"side": RIGHT}}
|
||||||
|
)
|
||||||
|
self.bottomWidgets[key].pack(side=LEFT)
|
||||||
|
|
||||||
def generateRom():
|
def generateRom():
|
||||||
guiargs = Namespace()
|
guiargs = Namespace()
|
||||||
guiargs.multi = int(parent.multiworldWindow.multiworldWidgets["worlds"].storageVar.get())
|
guiargs.multi = int(parent.multiworldWindow.multiworldWidgets["worlds"].storageVar.get())
|
||||||
guiargs.names = parent.multiworldWindow.namesVar.get()
|
guiargs.names = parent.multiworldWindow.namesVar.get()
|
||||||
guiargs.seed = int(parent.farBottomFrame.seedVar.get()) if parent.farBottomFrame.seedVar.get() else None
|
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.mode = parent.itemWindow.itemWidgets["worldstate"].storageVar.get()
|
||||||
guiargs.logic = parent.itemWindow.itemWidgets["logiclevel"].storageVar.get()
|
guiargs.logic = parent.itemWindow.itemWidgets["logiclevel"].storageVar.get()
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ def loadcliargs(gui,args):
|
|||||||
if args.multi:
|
if args.multi:
|
||||||
gui.multiworldWindow.multiworldWidgets["worlds"].storageVar.set(str(args.multi))
|
gui.multiworldWindow.multiworldWidgets["worlds"].storageVar.set(str(args.multi))
|
||||||
if args.count:
|
if args.count:
|
||||||
gui.farBottomFrame.countVar.set(str(args.count))
|
gui.farBottomFrame.bottomWidgets["generationcount"].storageVar.set(str(args.count))
|
||||||
if args.seed:
|
if args.seed:
|
||||||
gui.farBottomFrame.seedVar.set(str(args.seed))
|
gui.farBottomFrame.seedVar.set(str(args.seed))
|
||||||
gui.itemWindow.itemWidgets["worldstate"].storageVar.set(args.mode)
|
gui.itemWindow.itemWidgets["worldstate"].storageVar.set(args.mode)
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
from tkinter import Checkbutton, Entry, Frame, IntVar, Label, OptionMenu, Spinbox, StringVar, RIGHT
|
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):
|
def make_checkbox(self, parent, label, storageVar, packAttrs):
|
||||||
self = Frame(parent)
|
self = Frame(parent)
|
||||||
self.storageVar = storageVar
|
self.storageVar = storageVar
|
||||||
@@ -41,7 +54,7 @@ def make_spinbox(self, parent, label, storageVar, packAttrs):
|
|||||||
fromNum = packAttrs["spinbox"]["from"]
|
fromNum = packAttrs["spinbox"]["from"]
|
||||||
if "to" in packAttrs:
|
if "to" in packAttrs:
|
||||||
toNum = packAttrs["spinbox"]["to"]
|
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"])
|
self.spinbox.pack(packAttrs["spinbox"])
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user