Skip to content

Commit

Permalink
p/spoolmanager: Fix various GUI problems
Browse files Browse the repository at this point in the history
 * Set icons for every window.
 * Increase initial size of displayed list of spools and automate its
   resizing. (Partial fix for #905)
 * Fix error on the edit spool window: wx.Sizer.AddSpacer no longer
   accepts tuples as arguments.
  • Loading branch information
rockstorm101 committed Mar 18, 2018
1 parent e13e486 commit f265256
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions printrun/spoolmanager/spoolmanager_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def __init__(self, parent, spool_manager):

self.statusbar = self.CreateStatusBar()

self.SetIcon(parent.GetIcon())

# Initiate the back-end
self.spool_manager = spool_manager
self.spool_manager.refresh()
Expand Down Expand Up @@ -176,24 +178,32 @@ class SpoolListView(wx.ListView):
def __init__(self, parent, spool_manager):
wx.ListView.__init__(self, parent,
style = wx.LC_REPORT | wx.LC_SINGLE_SEL)
self.InsertColumn(0, "Spool")
self.InsertColumn(1, "Filament")
self.InsertColumn(0, "Spool", width = wx.LIST_AUTOSIZE_USEHEADER)
self.InsertColumn(1, "Filament", width = wx.LIST_AUTOSIZE_USEHEADER)
self.populateList(spool_manager)

# "Program" the layout
self.Bind(wx.EVT_SIZE, self.onResizeList)

def populateList(self, spool_manager):
"""Get the list of recorded spools from the Spool Manager."""
spool_list = spool_manager.getSpoolList()
print()
for i in range(len(spool_list)):
self.Append(spool_list[i])
self.SetColumnWidth(0, -1 | -2)
self.SetColumnWidth(1, -1 | -2)

def refreshList(self, spool_manager):
"""Refresh the list by re-reading the Spool Manager list."""
self.DeleteAllItems()
self.populateList(spool_manager)

def onResizeList(self, event):
list_size = self.GetSize()
self.SetColumnWidth(1, -2)
filament_column_width = self.GetColumnWidth(1)
self.SetColumnWidth(col = 0,
width = list_size.width - filament_column_width)
event.Skip()


class CurrentSpoolDialog(wx.Panel):
"""
Expand Down Expand Up @@ -305,6 +315,8 @@ def __init__(self, parent):

self.parent = parent

self.SetIcon(parent.GetIcon())

# Generate the dialogs
self.name_dialog = LabeledTextCtrl(self,
"Name", "Default Spool", "")
Expand Down Expand Up @@ -475,6 +487,8 @@ def __init__(self, parent, spool_name, spool_length):

self.parent = parent

self.SetIcon(parent.GetIcon())

self.old_spool_name = spool_name
self.old_spool_length = getFloat(self, spool_length)

Expand Down Expand Up @@ -521,13 +535,19 @@ def __init__(self, parent, spool_name, spool_length):
# Layout
## Group the length field and its correspondent buttons
self.length_sizer = wx.BoxSizer(wx.HORIZONTAL)
self.length_sizer.Add(self.minus3_button, 0, wx.FIXED_MINSIZE)
self.length_sizer.Add(self.minus2_button, 0, wx.FIXED_MINSIZE)
self.length_sizer.Add(self.minus1_button, 0, wx.FIXED_MINSIZE)
self.length_sizer.Add(self.minus3_button, 0,
wx.FIXED_MINSIZE | wx.ALIGN_CENTER)
self.length_sizer.Add(self.minus2_button, 0,
wx.FIXED_MINSIZE | wx.ALIGN_CENTER)
self.length_sizer.Add(self.minus1_button, 0,
wx.FIXED_MINSIZE | wx.ALIGN_CENTER)
self.length_sizer.Add(self.length_field, 1, wx.EXPAND)
self.length_sizer.Add(self.plus1_button, 0, wx.FIXED_MINSIZE)
self.length_sizer.Add(self.plus2_button, 0, wx.FIXED_MINSIZE)
self.length_sizer.Add(self.plus3_button, 0, wx.FIXED_MINSIZE)
self.length_sizer.Add(self.plus1_button, 0,
wx.FIXED_MINSIZE | wx.ALIGN_CENTER)
self.length_sizer.Add(self.plus2_button, 0,
wx.FIXED_MINSIZE | wx.ALIGN_CENTER)
self.length_sizer.Add(self.plus3_button, 0,
wx.FIXED_MINSIZE | wx.ALIGN_CENTER)

## Group the bottom buttons
self.bottom_buttons_sizer = wx.BoxSizer(wx.HORIZONTAL)
Expand All @@ -537,12 +557,12 @@ def __init__(self, parent, spool_name, spool_length):
## Lay out the whole window
self.full_sizer = wx.BoxSizer(wx.VERTICAL)
self.full_sizer.Add(self.name_field, 0, wx.EXPAND)
self.full_sizer.AddSpacer((-1,10))
self.full_sizer.AddSpacer(10)
self.full_sizer.Add(self.length_title, 0,
wx.LEFT | wx.RIGHT | wx.EXPAND, 10)
self.full_sizer.Add(self.length_sizer, 0,
wx.LEFT | wx.RIGHT | wx.EXPAND, 10)
self.full_sizer.AddSpacer((-1,10))
self.full_sizer.AddSpacer(10)
self.full_sizer.Add(self.bottom_buttons_sizer, 0, wx.ALIGN_CENTER)

self.SetSizerAndFit(self.full_sizer)
Expand Down

0 comments on commit f265256

Please sign in to comment.