Skip to content

Commit

Permalink
Made scrollwheel work in the update gui
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Nov 21, 2014
1 parent 5faa448 commit 9c7d867
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014
==============================================================================

v6.0.3 WIP
. (kfsone) Added a GUI to the "update" sub-command, it's experimental:
- Use <tab>/<shift-tab> to cycle across rows,
- Use <enter> to drop to the first column of the next line,
- Scrolling is currently broken - you have to manually scroll. Ick.
- Use the "--exp" flag to indicate your understanding it is experimental.
e.g.: trade.py update --exp aulin
. (kfsone) Fixed sqrt crash in buildCache.py in multi-station systems

BETA 3:
Expand Down
16 changes: 14 additions & 2 deletions commands/update_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
default=False,
dest='forceNa',
),
ParseArgument('--experimental-gui', '-G',
help="Use the experimental built-in GUI",
action='store_true',
default=False,
dest='gui',
),
MutuallyExclusiveGroup(
ParseArgument('--sublime',
help='Like --editor but uses Sublime Text (2 or 3), which is nice.',
Expand Down Expand Up @@ -288,8 +294,14 @@ def guidedUpdate(tdb, cmdenv):

def run(results, cmdenv, tdb):
if not cmdenv.editor and not cmdenv.editing:
guidedUpdate(tdb, cmdenv)
return None
if cmdenv.gui:
guidedUpdate(tdb, cmdenv)
return None
raise CommandLineError(
"The GUI for updates is currently experimental. "
"Either use one of the editors or specify the "
"--experimental-gui (--exp or -G for short) "
"flags.\n")

# User specified one of the options to use an editor.
editUpdate(tdb, cmdenv, cmdenv.startStation.ID)
Expand Down
11 changes: 9 additions & 2 deletions commands/update_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ def __init__(self, root, dbPath, stationID):
tk.Frame.__init__(self, root)

self.root = root
self.style = ttk.Style()
self.style.theme_use("default")

self.canvas = tk.Canvas(root, borderwidth=0, background="#ffffff")
self.frame = tk.Frame(self.canvas, background="#ffffff")
self.canvas = tk.Canvas(root, borderwidth=0)
self.canvas.bind_all("<MouseWheel>", self.onMouseWheel)
self.frame = tk.Frame(self.canvas)
self.vsb = tk.Scrollbar(root, orient="vertical", command=self.canvas.yview)
self.canvas.configure(yscrollcommand=self.vsb.set)

Expand All @@ -43,6 +46,10 @@ def onFrameConfigure(self, event):
self.canvas.configure(scrollregion=self.canvas.bbox("all"))


def onMouseWheel(self, event):
self.canvas.yview_scroll(int(-1 * (event.delta/120)), "units")


def query(self, itemName, pos):
item = self.items[itemName]
row = self.itemDisplays[item.displayNo]
Expand Down

0 comments on commit 9c7d867

Please sign in to comment.