Commit 0dc1bff4 authored by Russ Fish's avatar Russ Fish
Browse files

Fix a flock of little things in the hypview GUI:

 . Improve control panel layout by removing spacers and using Border spacing instead.
 . Start to make resizing work by setting Expand options in the GUI.
 . Change the LabelsMode widget from a wxComboBox to a wxChoice.
 . Disallow non-numeric chars and handle Enter in the "Node/Link depth" spinboxes.
 . Handle Enter in the Open dialog text fields; complain politely about empty text.
 . Disable show/hide buttons when there are no links in or out, respectively.
parent 63d9ab12
......@@ -62,17 +62,17 @@ class UsageDialogUI(wxDialog):
class OpenDialogUI(wxDialog):
def __init__(self, *args, **kwds):
# begin wxGlade: OpenDialogUI.__init__
kwds["style"] = wxDEFAULT_DIALOG_STYLE
kwds["style"] = wxCAPTION|wxRESIZE_BORDER|wxTHICK_FRAME
wxDialog.__init__(self, *args, **kwds)
self.FileToOpen = wxTextCtrl(self, -1, "")
self.FileToOpen = wxTextCtrl(self, -1, "", style=wxTE_PROCESS_ENTER)
self.OpenFile = wxButton(self, -1, "Open Data File")
self.FileMsg = wxStaticText(self, -1, "")
self.label_2 = wxStaticText(self, -1, "Project name:", style=wxALIGN_RIGHT)
self.ProjectName = wxTextCtrl(self, -1, "")
self.ProjectName = wxTextCtrl(self, -1, "", style=wxTE_PROCESS_ENTER)
self.label_7 = wxStaticText(self, -1, "Experiment name:")
self.ExperimentName = wxTextCtrl(self, -1, "")
self.ExperimentName = wxTextCtrl(self, -1, "", style=wxTE_PROCESS_ENTER)
self.label_8 = wxStaticText(self, -1, "Root (optional):")
self.ExperimentRoot = wxTextCtrl(self, -1, "")
self.ExperimentRoot = wxTextCtrl(self, -1, "", style=wxTE_PROCESS_ENTER)
self.OpenExperiment = wxButton(self, -1, "Retrieve experiment")
self.ExperimentMsg = wxStaticText(self, -1, "")
......@@ -83,38 +83,30 @@ class OpenDialogUI(wxDialog):
def __set_properties(self):
# begin wxGlade: OpenDialogUI.__set_properties
self.SetTitle("Open HyperViewer Data")
self.SetSize((416, 305))
self.FileToOpen.SetSize((400, 25))
self.ProjectName.SetSize((270, 25))
self.ExperimentName.SetSize((270, 25))
self.ExperimentRoot.SetSize((270, 25))
self.SetSize((387, 310))
# end wxGlade
def __do_layout(self):
# begin wxGlade: OpenDialogUI.__do_layout
sizer_4 = wxBoxSizer(wxVERTICAL)
ExperimentOpening = wxStaticBoxSizer(wxStaticBox(self, -1, "Experiment to retrieve:"), wxVERTICAL)
grid_sizer_1 = wxFlexGridSizer(4, 2, 10, 10)
grid_sizer_1 = wxFlexGridSizer(3, 2, 10, 10)
FileOpening = wxStaticBoxSizer(wxStaticBox(self, -1, "File for HyperViewer data:"), wxVERTICAL)
FileOpening.Add(self.FileToOpen, 0, 0, 0)
FileOpening.Add(20, 10, 0, 0, 0)
FileOpening.Add(self.OpenFile, 0, wxALIGN_CENTER_HORIZONTAL, 0)
FileOpening.Add(self.FileToOpen, 0, wxEXPAND, 0)
FileOpening.Add(self.OpenFile, 0, wxTOP|wxALIGN_CENTER_HORIZONTAL, 10)
FileOpening.Add(self.FileMsg, 0, 0, 0)
sizer_4.Add(FileOpening, 0, wxALL, 0)
sizer_4.Add(20, 10, 0, 0, 0)
sizer_4.Add(FileOpening, 0, wxALL|wxEXPAND, 10)
grid_sizer_1.Add(self.label_2, 0, 0, 0)
grid_sizer_1.Add(self.ProjectName, 0, 0, 0)
grid_sizer_1.Add(self.ProjectName, 0, wxEXPAND, 0)
grid_sizer_1.Add(self.label_7, 0, 0, 0)
grid_sizer_1.Add(self.ExperimentName, 0, 0, 0)
grid_sizer_1.Add(self.ExperimentName, 0, wxEXPAND, 0)
grid_sizer_1.Add(self.label_8, 0, 0, 0)
grid_sizer_1.Add(self.ExperimentRoot, 0, 0, 0)
grid_sizer_1.Add(20, 1, 0, 0, 0)
grid_sizer_1.Add(20, 1, 0, 0, 0)
grid_sizer_1.Add(self.ExperimentRoot, 0, wxEXPAND, 0)
grid_sizer_1.AddGrowableCol(1)
ExperimentOpening.Add(grid_sizer_1, 0, wxEXPAND, 0)
ExperimentOpening.Add(self.OpenExperiment, 0, wxALIGN_CENTER_HORIZONTAL, 0)
ExperimentOpening.Add(self.OpenExperiment, 0, wxTOP|wxALIGN_CENTER_HORIZONTAL, 10)
ExperimentOpening.Add(self.ExperimentMsg, 0, 0, 0)
ExperimentOpening.Add(20, 10, 0, 0, 0)
sizer_4.Add(ExperimentOpening, 1, wxALL, 0)
sizer_4.Add(ExperimentOpening, 0, wxALL|wxEXPAND, 10)
self.SetAutoLayout(1)
self.SetSizer(sizer_4)
self.Layout()
......@@ -145,15 +137,15 @@ class hvFrameUI(wxFrame):
# Menu Bar end
self.hypView = hvGLCanvas(self.panel_1, -1)
self.GoToTop = wxButton(self.Controls, -1, "go to top")
self.LabelNodeName = wxStaticText(self.Controls, -1, " Node name ")
self.LabelNodeName = wxStaticText(self.Controls, -1, "Node name:")
self.NodeName = wxTextCtrl(self.Controls, -1, "")
self.LabelChildCount = wxStaticText(self.Controls, -1, " Child count: ")
self.LabelChildCount = wxStaticText(self.Controls, -1, "Child count: ")
self.ChildCount = wxStaticText(self.Controls, -1, " 0")
self.LabelLinksIn = wxStaticText(self.Controls, -1, " Non-tree Links in: 0")
self.LabelLinksIn = wxStaticText(self.Controls, -1, "Non-tree Links in: 0")
self.ShowLinksIn = wxButton(self.Controls, -1, "show")
self.HideLinksIn = wxButton(self.Controls, -1, "hide")
self.DescendLinksIn = wxCheckBox(self.Controls, -1, "descend")
self.LabelLinksOut = wxStaticText(self.Controls, -1, " Non-tree Links out: 0")
self.LabelLinksOut = wxStaticText(self.Controls, -1, "Non-tree Links out: 0")
self.ShowLinksOut = wxButton(self.Controls, -1, "show")
self.HideLinksOut = wxButton(self.Controls, -1, "hide")
self.DescendLinksOut = wxCheckBox(self.Controls, -1, "descend")
......@@ -163,7 +155,7 @@ class hvFrameUI(wxFrame):
self.DrawLinks = wxCheckBox(self.Controls, -1, "Draw links")
self.KeepAspect = wxCheckBox(self.Controls, -1, "Keep aspect")
self.LabelToRight = wxCheckBox(self.Controls, -1, "Label to right")
self.LabelsMode = wxComboBox(self.Controls, -1, choices=["None", "Short", "Long"], style=wxCB_DROPDOWN)
self.LabelsMode = wxChoice(self.Controls, -1, choices=["None", "Short", "Long"], style=wxCB_DROPDOWN)
self.label_3 = wxStaticText(self.Controls, -1, " Labels")
self.CountGenNode = wxSpinCtrl(self.Controls, -1, "30", min=1, max=30)
self.label_4 = wxStaticText(self.Controls, -1, " Node depth")
......@@ -181,27 +173,33 @@ class hvFrameUI(wxFrame):
def __set_properties(self):
# begin wxGlade: hvFrameUI.__set_properties
self.SetTitle("wxHyperViewer")
self.SetSize((760, 622))
self.hypView.SetSize((558, 594))
self.panel_1.SetSize((378, 586))
self.NodeName.SetSize((110, 25))
self.SetSize((760, 651))
self.hypView.SetSize((559, 693))
self.panel_1.SetSize((517, 615))
self.ShowLinksIn.Enable(0)
self.HideLinksIn.Enable(0)
self.DescendLinksIn.Enable(0)
self.DescendLinksIn.SetValue(1)
self.ShowLinksOut.Enable(0)
self.HideLinksOut.Enable(0)
self.DescendLinksOut.Enable(0)
self.DescendLinksOut.SetValue(1)
self.DrawSphere.SetValue(1)
self.DrawNodes.SetValue(1)
self.DrawLinks.SetValue(1)
self.KeepAspect.SetValue(1)
self.LabelsMode.SetSize((100, 25))
self.LabelsMode.SetSize((70, 25))
self.LabelsMode.SetSelection(2)
self.CountGenNode.SetSize((95, 25))
self.CountGenNode.SetSize((70, 25))
self.CountGenNode.SetToolTipString("Generation Node Limit")
self.label_4.SetToolTipString("Generation Link Limit")
self.CountGenLink.SetSize((70, 25))
self.CountGenLink.SetToolTipString("Generation Link Limit")
self.label_5.SetToolTipString("Generation Link Limit")
self.AnimStepCount.SetSize((150, 40))
self.AnimStepCount.SetToolTipString("Number of frames per animation")
self.label_6.SetToolTipString("Number of frames per animation")
self.window_1.SetSize((760, 590))
self.window_1.SetSize((760, 619))
self.window_1.SplitVertically(self.panel_1, self.Controls)
# end wxGlade
......@@ -223,50 +221,45 @@ class hvFrameUI(wxFrame):
sizer_3.Add(self.hypView, 99, 0, 0)
self.panel_1.SetAutoLayout(1)
self.panel_1.SetSizer(sizer_3)
Nodes.Add(self.GoToTop, 0, 0, 0)
sizer_6.Add(self.LabelNodeName, 0, 0, 0)
sizer_6.Add(self.NodeName, 0, 0, 0)
Nodes.Add(self.GoToTop, 0, 0, 15)
sizer_6.Add(self.LabelNodeName, 0, 0, 10)
sizer_6.Add(self.NodeName, 1, wxLEFT|wxEXPAND, 5)
Nodes.Add(sizer_6, 1, wxEXPAND, 0)
Nodes.Add(20, 10, 0, 0, 0)
sizer_7.Add(self.LabelChildCount, 0, 0, 0)
sizer_7.Add(self.LabelChildCount, 0, 0, 10)
sizer_7.Add(self.ChildCount, 0, 0, 0)
Nodes.Add(sizer_7, 1, wxEXPAND, 0)
Nodes.Add(self.LabelLinksIn, 0, 0, 0)
sizer_8.Add(20, 20, 0, 0, 0)
sizer_8.Add(self.ShowLinksIn, 0, 0, 0)
Nodes.Add(self.LabelLinksIn, 0, 0, 10)
sizer_8.Add(self.ShowLinksIn, 0, wxLEFT, 15)
sizer_8.Add(self.HideLinksIn, 0, 0, 0)
Nodes.Add(sizer_8, 1, wxEXPAND, 0)
Nodes.Add(sizer_8, 1, 0, 0)
Nodes.Add(self.DescendLinksIn, 0, wxALIGN_CENTER_HORIZONTAL, 0)
Nodes.Add(self.LabelLinksOut, 0, 0, 0)
sizer_9.Add(20, 20, 0, 0, 0)
sizer_9.Add(self.ShowLinksOut, 0, 0, 0)
Nodes.Add(self.LabelLinksOut, 0, wxTOP, 10)
sizer_9.Add(self.ShowLinksOut, 0, wxLEFT, 15)
sizer_9.Add(self.HideLinksOut, 0, 0, 0)
Nodes.Add(sizer_9, 1, wxEXPAND, 0)
Nodes.Add(sizer_9, 1, 0, 0)
Nodes.Add(self.DescendLinksOut, 0, wxALIGN_CENTER_HORIZONTAL, 0)
sizer_2.Add(Nodes, 0, 0, 0)
sizer_2.Add(self.static_line_1, 0, wxEXPAND, 0)
Modes.Add(self.DrawSphere, 0, 0, 0)
sizer_2.Add(Nodes, 0, wxALL|wxEXPAND, 10)
sizer_2.Add(self.static_line_1, 0, wxEXPAND, 10)
Modes.Add(self.DrawSphere, 0, 0, 10)
Modes.Add(self.DrawNodes, 0, 0, 0)
Modes.Add(self.DrawLinks, 0, 0, 0)
Modes.Add(self.KeepAspect, 0, 0, 0)
Modes.Add(self.LabelToRight, 0, 0, 0)
Modes.Add(self.LabelToRight, 0, wxTOP, 10)
Labels.Add(self.LabelsMode, 0, 0, 0)
Labels.Add(self.label_3, 0, 0, 0)
Modes.Add(Labels, 0, 0, 0)
GenNodeLimit.Add(self.CountGenNode, 0, 0, 0)
GenNodeLimit.Add(self.CountGenNode, 0, 0, 10)
GenNodeLimit.Add(self.label_4, 0, 0, 0)
Modes.Add(GenNodeLimit, 0, 0, 0)
Modes.Add(GenNodeLimit, 0, wxTOP, 15)
GenLinkLimit.Add(self.CountGenLink, 0, 0, 0)
GenLinkLimit.Add(self.label_5, 0, 0, 0)
Modes.Add(GenLinkLimit, 0, 0, 0)
AnimSteps.Add(self.AnimStepCount, 0, wxBOTTOM, 0)
AnimSteps.Add(self.label_6, 0, 0, 0)
Modes.Add(AnimSteps, 0, 0, 0)
sizer_2.Add(Modes, 0, 0, 0)
sizer_2.Add(20, 20, 0, 0, 0)
sizer_2.Add(self.static_line_2, 0, wxEXPAND, 0)
sizer_2.Add(20, 10, 0, 0, 0)
sizer_2.Add(self.HelpButton, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0)
Modes.Add(AnimSteps, 0, wxTOP, 10)
sizer_2.Add(Modes, 0, wxALL, 10)
sizer_2.Add(self.static_line_2, 0, wxTOP|wxBOTTOM|wxEXPAND, 10)
sizer_2.Add(self.HelpButton, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10)
self.Controls.SetAutoLayout(1)
self.Controls.SetSizer(sizer_2)
sizer_2.Fit(self.Controls)
......
This diff is collapsed.
......@@ -119,6 +119,7 @@ class hvFrame(hvFrameUI):
self.vwr = None # Load data under the File menu now.
# Control events. (HyperViewer events are connected after loading data.)
# (These EVT_ handler functions are defined in site-packages/wxPython/wx.py .)
EVT_CHECKBOX(self.DrawSphere, -1, self.OnDrawSphere)
EVT_CHECKBOX(self.DrawNodes, -1, self.OnDrawNodes)
EVT_CHECKBOX(self.DrawLinks, -1, self.OnDrawLinks)
......@@ -130,13 +131,15 @@ class hvFrame(hvFrameUI):
EVT_BUTTON(self.ShowLinksOut, -1, self.OnShowLinksOut)
EVT_BUTTON(self.HideLinksOut, -1, self.OnHideLinksOut)
EVT_BUTTON(self.HelpButton, -1, self.OnUsage)
EVT_COMBOBOX(self.LabelsMode, -1, self.OnLabelsMode)
EVT_CHOICE(self.LabelsMode, -1, self.OnLabelsMode)
EVT_MENU(self, 1, self.OnOpen)
EVT_MENU(self, 2, self.OnExit)
EVT_MENU(self, 3, self.OnUsage)
EVT_SPINCTRL(self.CountGenNode, -1, self.OnCountGenNode)
EVT_CHAR(self.CountGenNode, self.OnCountGenNode_CHAR)
EVT_SPINCTRL(self.CountGenLink, -1, self.OnCountGenLink)
EVT_CHAR(self.CountGenLink, self.OnCountGenLink_CHAR)
# Other events.
EVT_CLOSE(self, self.OnExit)
# These do nothing until the vwr is instantiated below.
......@@ -201,10 +204,20 @@ class hvFrame(hvFrameUI):
self.NodeName.Clear()
self.NodeName.WriteText(node)
self.ChildCount.SetLabel(str(self.vwr.getChildCount(node)))
linksIn = self.vwr.getIncomingCount(node)
self.LabelLinksIn.SetLabel(
" Non-tree Links in: " + str(self.vwr.getIncomingCount(node)))
"Non-tree Links in: " + str(linksIn))
self.ShowLinksIn.Enable(linksIn > 0)
self.HideLinksIn.Enable(linksIn > 0)
self.DescendLinksIn.Enable(linksIn > 0)
linksOut = self.vwr.getOutgoingCount(node)
self.LabelLinksOut.SetLabel(
" Non-tree Links out: " + str(self.vwr.getOutgoingCount(node)))
"Non-tree Links out: " + str(linksOut))
self.ShowLinksOut.Enable(linksOut > 0)
self.HideLinksOut.Enable(linksOut > 0)
self.DescendLinksOut.Enable(linksOut > 0)
pass
##
......@@ -258,12 +271,44 @@ class hvFrame(hvFrameUI):
##
# Spin controls set integer state.
def OnCountGenNode(self, spinEvent):
##print "OnCountGenNode", self.vwr
if self.vwr is None:
return
self.vwr.setGenerationNodeLimit(self.CountGenNode.GetValue())
self.DrawGL()
pass
def OnCountGenLink(self, spinEvent):
##print "OnCountGenLink", self.vwr
if self.vwr is None:
return
self.vwr.setGenerationLinkLimit(self.CountGenLink.GetValue())
self.DrawGL()
pass
##
# Actions for <ENTER> keypress in numeric fields.
def OnCountGenNode_CHAR(self, keyEvent):
key = keyEvent.GetKeyCode()
if key == WXK_RETURN:
self.OnCountGenNode(keyEvent)
pass
self.OnCharDigitsOnly(keyEvent)
pass
def OnCountGenLink_CHAR(self, keyEvent):
key = keyEvent.GetKeyCode()
if key == WXK_RETURN:
self.OnCountGenLink(keyEvent)
pass
self.OnCharDigitsOnly(keyEvent)
pass
##
# Disable typing non-digits in numeric fields.
def OnCharDigitsOnly(self, keyEvent):
key = keyEvent.GetKeyCode()
if ord('0') <= key <= ord('9') or key in (WXK_BACK, WXK_TAB) or key >= WXK_DELETE:
keyEvent.Skip() # Skip actually means to process the event...
##
# Menu items issue commands from the menu bar.
def OnExit(self, cmdEvent):
......@@ -358,19 +403,30 @@ class hvOpen(OpenDialogUI):
OpenDialogUI.__init__(self, *args, **kwds)
EVT_BUTTON(self.OpenFile, -1, self.OnOpenFile)
EVT_TEXT_ENTER(self.FileToOpen, -1, self.OnOpenFile)
EVT_BUTTON(self.OpenExperiment, -1, self.OnOpenExperiment)
EVT_TEXT_ENTER(self.ProjectName, -1, self.OnOpenExperiment)
EVT_TEXT_ENTER(self.ExperimentName, -1, self.OnOpenExperiment)
EVT_TEXT_ENTER(self.ExperimentRoot, -1, self.OnOpenExperiment)
pass
##
# Get topology data from a file.
def OnOpenFile(self, cmdEvent):
file = self.FileToOpen.GetLineText(0)
msg = 'Reading topology file "%s".' % file
if file == "":
msg = "Enter a file path."
else:
msg = 'Reading topology file "%s".' % file
print msg
self.FileMsg.SetLabel(msg)
self.Refresh()
self.Update()
if file == "":
return
if self.app.frame.ReadTopFile("wxHyperViewer", file):
self.Hide(); # Success.
self.FileMsg.SetLabel(" ")
......@@ -386,12 +442,17 @@ class hvOpen(OpenDialogUI):
experiment = self.ExperimentName.GetLineText(0)
root = self.ExperimentRoot.GetLineText(0)
msg = 'Getting experiment %s/%s.' % (project, experiment)
if project == "" or experiment == "":
msg = "Enter a project name and experiment."
else:
msg = 'Getting experiment %s/%s.' % (project, experiment)
print msg
self.ExperimentMsg.SetLabel(msg)
self.Refresh()
self.Update()
if project == "" or experiment == "":
return
hypfile = exptToHv.getExperiment(project, experiment, root)
if type(hypfile) is types.ListType:
exptError = '%s %s\n%s' % tuple(hypfile[1:4])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment