|
To do a simple binary branching, I basically lifted the following from SPSS Programming and Data Management, with minor changes. Now I would like a UI to do the following: Have a dialog box come up with 5 preset values for the variables: percentage lv11 thru percentage lvl5 that asks the user: Do you want to change them? If yes, the dialog box gives user opportunity to type over existing values that are then available within Python, or no, and you are done. Can I accomplish this using either Tkinter or wxpython? Thanks.
BEGIN PROGRAM. import wx, spss app = wx.PySimpleApp() dlg = wx.MessageDialog(None, "OK to Run Monthly Statistics?", caption="Important Question", style=wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) ret = dlg.ShowModal() if ret ==wx.ID_YES: spss.Submit(["get file='c:/users/bruce/documents/data_xout14_0708.sav'.", more spss commands.]) END PROGRAM. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
wxPython can handle this (Tkinter could, too, but wxPython is better). To keep this really simple, there are two possibilities close to what you want.
To present a list of choices the user can select from but not edit individually, use wx.MultiChoiceDialog. Here's an example I did a few years ago for a class. It presents a variable list and runs DESCRIPTIVES on it (Now I would do this with the Custom Dialog Builder of version 17, instead.) Beware of listserver mangling of indentation below. import wx, spss, spssaux spssaux.OpenDataFile("cars.sav") vardict = spssaux.VariableDict(variableLevel=['scale']) choicelist = vardict.variables if choicelist: app = wx.PySimpleApp() dlg = wx.MultiChoiceDialog(None, "Select one or more variables\nfor analysis", "Descriptive Statistics", choicelist) if dlg.ShowModal() == wx.ID_OK: vars = dlg.GetSelections() else: vars = None dlg.Destroy() app.Destroy() if vars: varlist = [choicelist[i] for i in vars] spss.Submit("DESCRIPTIVES " + " ".join(varlist)) Another way that allows user editing but leaves you with a single string to parse is to use wx.TextEntryDialog. app = wx.PySimpleApp() dlg = wx.TextEntryDialog(None, "some message", "title", "default value", style=wx.OK|wx.CANCEL) if dialog.ShowModal() == wx.OK: <do something> dialog.Destroy() app.Destroy() HTH, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Colton Sent: Wednesday, October 01, 2008 9:16 AM To: [hidden email] Subject: [SPSSX-L] Python UI To do a simple binary branching, I basically lifted the following from SPSS Programming and Data Management, with minor changes. Now I would like a UI to do the following: Have a dialog box come up with 5 preset values for the variables: percentage lv11 thru percentage lvl5 that asks the user: Do you want to change them? If yes, the dialog box gives user opportunity to type over existing values that are then available within Python, or no, and you are done. Can I accomplish this using either Tkinter or wxpython? Thanks. BEGIN PROGRAM. import wx, spss app = wx.PySimpleApp() dlg = wx.MessageDialog(None, "OK to Run Monthly Statistics?", caption="Important Question", style=wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) ret = dlg.ShowModal() if ret ==wx.ID_YES: spss.Submit(["get file='c:/users/bruce/documents/data_xout14_0708.sav'.", more spss commands.]) END PROGRAM. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
