Пример #1
0
                     event):  # wxGlade: All_Widgets_Frame.<event_handler>
        print("Event handler 'onShowManual' not implemented!")
        event.Skip()

    def OnNotebookPageChanged(
            self, event):  # wxGlade: All_Widgets_Frame.<event_handler>
        print("Event handler 'OnNotebookPageChanged' not implemented!")
        event.Skip()

    def OnNotebookPageChanging(
            self, event):  # wxGlade: All_Widgets_Frame.<event_handler>
        print("Event handler 'OnNotebookPageChanging' not implemented!")
        event.Skip()

    def onStartConverting(self,
                          event):  # wxGlade: All_Widgets_Frame.<event_handler>
        print("Event handler 'onStartConverting' not implemented!")
        event.Skip()


# end of class All_Widgets_Frame
if __name__ == "__main__":
    gettext.install(
        "AllWidgets28App")  # replace with the appropriate catalog name

    AllWidgets28App = wx.PySimpleApp()
    All_Widgets = All_Widgets_Frame(None, wx.ID_ANY, "")
    AllWidgets28App.SetTopWindow(All_Widgets)
    All_Widgets.Show()
    AllWidgets28App.MainLoop()
Пример #2
0
def run(config="C:\\temp\\env_plots2_last_config.cfg", newSession=False):
    app = wx.PySimpleApp()
    frame = FrameMain(None, newSession, config)
    frame.Show(True)
    app.MainLoop()
Пример #3
0
def main():
    app = wx.PySimpleApp()
    frame = viewWindow(None)
    frame.Center()
    frame.Show()
    app.MainLoop()
Пример #4
0
        self.button.SetDefault()
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrameGrid.__do_layout
        self._szr_frame = wx.BoxSizer(wx.VERTICAL)
        self.grid_sizer = wx.FlexGridSizer(3, 1, 0, 0)
        self.grid_sizer.Add(self.grid, 1, wx.EXPAND, 0)
        self.grid_sizer.Add(self.static_line, 0, wx.ALL | wx.EXPAND, 5)
        self.grid_sizer.Add(self.button, 0, wx.ALIGN_RIGHT | wx.ALL, 5)
        self.grid_sizer.AddGrowableRow(0)
        self.grid_sizer.AddGrowableCol(0)
        self._szr_frame.Add(self.grid_sizer, 1, wx.EXPAND, 0)
        self.SetSizer(self._szr_frame)
        self._szr_frame.SetSizeHints(self)
        self.Layout()
        # end wxGlade


# end of class MyFrameGrid

if __name__ == "__main__":
    gettext.install(
        "ComplexExampleApp")  # replace with the appropriate catalog name

    ComplexExampleApp = wx.PySimpleApp()
    Mp3_To_Ogg = PyOgg2_MyFrame(None, wx.ID_ANY, "")
    ComplexExampleApp.SetTopWindow(Mp3_To_Ogg)
    Mp3_To_Ogg.Show()
    ComplexExampleApp.MainLoop()
Пример #5
0
            if type(item) == str:
                self.tree.AppendItem(parentItem, item)
            else:
                newItem = self.tree.AppendItem(parentItem, item[0])
                self.AddTreeNodes(newItem, item[1])
                
    def GetItemText(self, item):
        if item:
            return self.tree.GetItemText(item)
        else:
            return ""
        
    def OnItemExpanded(self, evt):
        print "OnItemExpanded: ", self.GetItemText(evt.GetItem())
        
    def OnItemCollapsed(self, evt):
        print "OnItemCollapsed:", self.GetItemText(evt.GetItem())

    def OnSelChanged(self, evt):
        print "OnSelChanged:   ", self.GetItemText(evt.GetItem())

    def OnActivated(self, evt):
        print "OnActivated:    ", self.GetItemText(evt.GetItem())


app = wx.PySimpleApp(redirect=True)
frame = TestFrame()
frame.Show()
app.MainLoop()

Пример #6
0
def main(args):
    if not args or ("-h" in args):
        print __doc__
        return

    # some bitmap related things need to have a wxApp initialized...
    if wx.GetApp() is None:
        app = wx.PySimpleApp()

    append = 0
    compressed = 1
    maskClr = None
    imgName = ""
    icon = 0
    catalog = 0

    try:
        opts, fileArgs = getopt.getopt(args, "auicn:m:")
    except getopt.GetoptError:
        print __doc__
        return

    for opt, val in opts:
        if opt == "-a":
            append = 1
        elif opt == "-u":
            compressed = 0
        elif opt == "-n":
            imgName = val
        elif opt == "-m":
            maskClr = val
        elif opt == "-i":
            icon = 1
        elif opt == "-c":
            catalog = 1

    if len(fileArgs) != 2:
        print __doc__
        return

    image_file, python_file = fileArgs

    # convert the image file to a temporary file
    tfname = tempfile.mktemp()
    ok, msg = img2img.convert(image_file, maskClr, None, tfname,
                              wx.BITMAP_TYPE_PNG, ".png")
    if not ok:
        print msg
        return

    data = open(tfname, "rb").read()
    data = crunch_data(data, compressed)
    os.unlink(tfname)

    if append:
        out = open(python_file, "a")
    else:
        out = open(python_file, "w")

    if catalog:
        pyPath, pyFile = os.path.split(python_file)
        imgPath, imgFile = os.path.split(image_file)

        if not imgName:
            imgName = os.path.splitext(imgFile)[0]
            print "\nWarning: -n not specified. Using filename (%s) for catalog entry." % imgName

        old_index = []
        if append:
            # check to see if catalog exists already (file may have been created
            # with an earlier version of img2py or without -c option)
            oldSysPath = sys.path[:]
            sys.path = [
                pyPath
            ]  # make sure we don't import something else by accident
            mod = __import__(os.path.splitext(pyFile)[0])
            if 'index' not in dir(mod):
                print "\nWarning: %s was originally created without catalog." % python_file
                print "         Any images already in file will not be cataloged.\n"
                out.write(
                    "\n# ***************** Catalog starts here *******************"
                )
                out.write("\n\ncatalog = {}\n")
                out.write("index = []\n\n")
                out.write("class ImageClass: pass\n\n")
            else:  # save a copy of the old index so we can warn about duplicate names
                old_index[:] = mod.index[:]
            del mod
            sys.path = oldSysPath[:]

    out.write("#" + "-" * 70 + "\n")
    if not append:
        out.write("# This file was generated by %s\n#\n" % sys.argv[0])
        out.write("from wx from PIL import ImageFromStream, BitmapFromImage\n")
        if icon:
            out.write("from wx import EmptyIcon\n")
        if compressed:
            out.write("import cStringIO, zlib\n\n\n")
        else:
            out.write("import cStringIO\n\n\n")

        if catalog:
            out.write("catalog = {}\n")
            out.write("index = []\n\n")
            out.write("class ImageClass: pass\n\n")

    if compressed:
        out.write("def get%sData():\n"
                  "    return zlib.decompress(\n%s)\n\n" % (imgName, data))
    else:
        out.write("def get%sData():\n"
                  "    return \\\n%s\n\n" % (imgName, data))

    out.write("def get%sBitmap():\n"
              "    return BitmapFromImage(get%sImage())\n\n"
              "def get%sImage():\n"
              "    stream = cStringIO.StringIO(get%sData())\n"
              "    return ImageFromStream(stream)\n\n" % tuple([imgName] * 4))
    if icon:
        out.write("def get%sIcon():\n"
                  "    icon = EmptyIcon()\n"
                  "    icon.CopyFromBitmap(get%sBitmap())\n"
                  "    return icon\n\n" % tuple([imgName] * 2))

    if catalog:
        if imgName in old_index:
            print "Warning: %s already in catalog." % imgName
            print "         Only the last entry will be accessible.\n"
        old_index.append(imgName)
        out.write("index.append('%s')\n" % imgName)
        out.write("catalog['%s'] = ImageClass()\n" % imgName)
        out.write("catalog['%s'].getData = get%sData\n" % tuple([imgName] * 2))
        out.write("catalog['%s'].getImage = get%sImage\n" %
                  tuple([imgName] * 2))
        out.write("catalog['%s'].getBitmap = get%sBitmap\n" %
                  tuple([imgName] * 2))
        if icon:
            out.write("catalog['%s'].getIcon = get%sIcon\n" %
                      tuple([imgName] * 2))
        out.write("\n\n")

    if imgName:
        n_msg = ' using "%s"' % imgName
    else:
        n_msg = ""
    if maskClr:
        m_msg = " with mask %s" % maskClr
    else:
        m_msg = ""
    print "Embedded %s%s into %s%s" % (image_file, n_msg, python_file, m_msg)
Пример #7
0
        pass

    def write(self, msg):
        print msg

#----------------------------------------------------------------------

overview = eclib.outbuff.__doc__
title = "OutputBuffer"

#-----------------------------------------------------------------------------#
# Run the Test
if __name__ == '__main__':
    try:
        import run
    except ImportError:
        app = wx.PySimpleApp(False)
        frame = wx.Frame(None, title="OutputBuffer Test 'Ping-O-Matic'")
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(TestPanel(frame, TestLog()), 1, wx.EXPAND)
        frame.CreateStatusBar()
        frame.SetSizer(sizer)
        frame.SetInitialSize((500, 500))
        frame.SetStatusText("OutputBufferDemo: wxPython %s, Python %s" % \
                            (wx.__version__, u".".join(str(x) for x in sys.version_info)))
        frame.CenterOnParent()
        frame.Show()
        app.MainLoop()
    else:
        run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
Пример #8
0
def RunStandalone():
    app = wx.PySimpleApp()
    frame = wx.Frame(None, -1, "Test MaskedEditCtrls", size=(640, 480))
    win = TestMaskedTextCtrls(frame, -1, sys.stdout)
    frame.Show(True)
    app.MainLoop()
Пример #9
0
        lang_ids = GetLocaleDict(GetAvailLocales()).values()
        lang_items = langlist.CreateLanguagesResourceLists(langlist.LC_ONLY, \
                                                           lang_ids)
        wx.combo.BitmapComboBox.__init__(self,
                                         parent,
                                         id_,
                                         size=wx.Size(250, 26),
                                         style=wx.CB_READONLY)
        for lang_d in lang_items[1]:
            bit_m = lang_items[0].GetBitmap(lang_items[1].index(lang_d))
            self.Append(lang_d, bit_m)

        if default:
            self.SetValue(default)


#-----------------------------------------------------------------------------#
if __name__ == '__main__':
    APP = wx.PySimpleApp(False)
    # Print a list of Cannonical names usefull for seeing what codes to
    # use when naming po files
    OUT = list()
    for LANG in [x for x in dir(wx) if x.startswith("LANGUAGE")]:
        LOC_I = wx.Locale(wx.LANGUAGE_DEFAULT).\
                         GetLanguageInfo(getattr(wx, LANG))
        if LOC_I:
            OUT.append(LOC_I.CanonicalName)

    for LANG in sorted(OUT):
        print LANG
Пример #10
0
def main():
    app = wx.PySimpleApp()
    f = LcdTest()
    app.MainLoop()
Пример #11
0
 def run(self):
     app = wx.PySimpleApp()
     ArvaFrame(None, self.sensex, self.sensey, self.maxscale, self.minscale)
     app.MainLoop()
Пример #12
0
from __future__ import print_function
import sys, os

import wx
if wx.version() < '2.9':
    tmpApp = wx.PySimpleApp()
else:
    tmpApp = wx.App(False)
from psychopy.app import builder, projects
from psychopy.app.builder.components import getAllComponents

# usage: generate or compare all Component.param settings & options

# motivation: catch deviations introduced during refactoring

# use --out to re-generate componsTemplate.txt

# ignore attributes that are there because inherit from object
ignoreObjectAttribs = True

origProjectCatalog = projects.projectCatalog
projects.projectCatalog = {}

# should not need a wx.App with fetchIcons=False
try:
    allComp = getAllComponents(fetchIcons=False)
except Exception:
    import wx
    if wx.version() < '2.9':
        tmpApp = wx.PySimpleApp()
    else:
Пример #13
0
def ensureMinimal(minVersion, optionsRequired=False):
    """
    Checks to see if the default version of wxPython is greater-than
    or equal to `minVersion`.  If not then it will try to find an
    installed version that is >= minVersion.  If none are available
    then a message is displayed that will inform the user and will
    offer to open their web browser to the wxPython downloads page,
    and will then exit the application.
    """
    assert type(minVersion) == str

    # ensure that wxPython hasn't been imported yet.
    if sys.modules.has_key('wx') or sys.modules.has_key('wxPython'):
        raise VersionError(
            "wxversion.ensureMinimal() must be called before wxPython is imported"
        )

    bestMatch = None
    minv = _wxPackageInfo(minVersion)

    # check the default version first
    defaultPath = _find_default()
    if defaultPath:
        defv = _wxPackageInfo(defaultPath, True)
        if defv >= minv and minv.CheckOptions(defv, optionsRequired):
            bestMatch = defv

    # if still no match then check look at all installed versions
    if bestMatch is None:
        installed = _find_installed()
        # The list is in reverse sorted order, so find the first
        # one that is big enough and optionally matches the
        # options
        for inst in installed:
            if inst >= minv and minv.CheckOptions(inst, optionsRequired):
                bestMatch = inst
                break

    # if still no match then prompt the user
    if bestMatch is None:
        if _EM_DEBUG:  # We'll do it this way just for the test code below
            raise VersionError("Requested version of wxPython not found")

        import wx, webbrowser
        versions = "\n".join(["      " + ver for ver in getInstalled()])
        app = wx.PySimpleApp()
        result = wx.MessageBox(
            "This application requires a version of wxPython "
            "greater than or equal to %s, but a matching version "
            "was not found.\n\n"
            "You currently have these version(s) installed:\n%s\n\n"
            "Would you like to download a new version of wxPython?\n" %
            (minVersion, versions),
            "wxPython Upgrade Needed",
            style=wx.YES_NO)
        if result == wx.YES:
            webbrowser.open(UPDATE_URL)
        app.MainLoop()
        sys.exit()

    sys.path.insert(0, bestMatch.pathname)
    # q.v. Bug #1409256
    path64 = re.sub('/lib/', '/lib64/', bestMatch.pathname)
    if os.path.isdir(path64):
        sys.path.insert(0, path64)
    global _selected
    _selected = bestMatch
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#  Enquires: [email protected] or [email protected]

import wx
import StringIO

application = wx.PySimpleApp()

# Create a list of filters

# This should be fairly simple to follow, so no explanation is necessary

filters = 'EC2 Credentials files (*.zip)|*.zip'

dialog = wx.FileDialog(None,
                       message='Open something....',
                       wildcard=filters,
                       style=wx.OPEN)

if dialog.ShowModal() == wx.ID_OK:

    # We'll have to make room for multiple files here
Пример #15
0
def start_hci():
    app = wx.PySimpleApp()
    f = MainFrame(parent=None, id=-1)
    f.Show()
    app.MainLoop()
Пример #16
0
# This module requires IPython to work! It is meant to be used from an IPython environment with: 
#   ipython -wthread and -pylab
# See demo_pykinect.py for an example

import wx
from wx import glcanvas
from OpenGL.GL import *

# Get the app ourselves so we can attach it to each window
if not '__myapp' in wx.__dict__:
  wx.__myapp = wx.PySimpleApp()
app = wx.__myapp

class Window(wx.Frame):
  
    # wx events can be put in directly
    def eventx(self, target):
        def wrapper(*args, **kwargs):
          target(*args, **kwargs)
        self.canvas.Bind(wx.__dict__[target.__name__], wrapper)
  
    # Events special to this class, just add them this way
    def event(self, target):
        def wrapper(*args, **kwargs):
          target(*args, **kwargs)   
        self.__dict__[target.__name__] = wrapper
        
    def _wrap(self, name, *args, **kwargs):
      try:
        self.__getattribute__(name)
      except AttributeError:
Пример #17
0
class PyOgg1_MyDialog(wx.Dialog):
    def __init__(self, *args, **kwds):
        # begin wxGlade: PyOgg1_MyDialog.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
        wx.Dialog.__init__(self, *args, **kwds)
        self.SetSize((500, 300))
        self.SetTitle(_("mp3 2 ogg"))
        self.SetSize((500, 300))
        self.SetFocus()
        
        sizer_1 = wx.FlexGridSizer(3, 1, 0, 0)
        
        self.notebook_1 = wx.Notebook(self, wx.ID_ANY, style=0)
        sizer_1.Add(self.notebook_1, 1, wx.EXPAND, 0)
        
        self.notebook_1_pane_1 = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_pane_1, _("Input File"))
        
        grid_sizer_1 = wx.FlexGridSizer(1, 3, 0, 0)
        
        label_1 = wx.StaticText(self.notebook_1_pane_1, wx.ID_ANY, _("File name:"))
        grid_sizer_1.Add(label_1, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        
        self.text_ctrl_1 = wx.TextCtrl(self.notebook_1_pane_1, wx.ID_ANY, "")
        grid_sizer_1.Add(self.text_ctrl_1, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL | wx.EXPAND, 5)
        
        self.button_3 = wx.Button(self.notebook_1_pane_1, wx.ID_OPEN, "")
        grid_sizer_1.Add(self.button_3, 0, wx.ALL, 5)
        
        self.notebook_1_pane_2 = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_pane_2, _("Converting Options"))
        
        sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
        
        self.radio_box_1 = wx.RadioBox(self.notebook_1_pane_2, wx.ID_ANY, _("Sampling Rate"), choices=[_("44 kbit"), _("128 kbit")], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
        self.radio_box_1.SetSelection(0)
        sizer_4.Add(self.radio_box_1, 0, wx.ALL | wx.EXPAND | wx.SHAPED, 5)
        
        self.notebook_1_pane_3 = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_pane_3, _("Converting Progress"))
        
        sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
        
        self.text_ctrl_2 = wx.TextCtrl(self.notebook_1_pane_3, wx.ID_ANY, "", style=wx.TE_MULTILINE)
        sizer_3.Add(self.text_ctrl_2, 1, wx.ALL | wx.EXPAND, 5)
        
        self.notebook_1_pane_4 = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.notebook_1.AddPage(self.notebook_1_pane_4, _("Output File"))
        
        grid_sizer_2 = wx.FlexGridSizer(2, 3, 0, 0)
        
        self.label_2 = wx.StaticText(self.notebook_1_pane_4, wx.ID_ANY, _("File name:"))
        grid_sizer_2.Add(self.label_2, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)
        
        self.text_ctrl_3 = wx.TextCtrl(self.notebook_1_pane_4, wx.ID_ANY, "")
        grid_sizer_2.Add(self.text_ctrl_3, 0, wx.ALL | wx.EXPAND, 5)
        
        self.button_4 = wx.Button(self.notebook_1_pane_4, wx.ID_OPEN, "")
        grid_sizer_2.Add(self.button_4, 0, wx.ALL, 5)
        
        grid_sizer_2.Add((20, 20), 0, 0, 0)
        
        self.checkbox_1 = wx.CheckBox(self.notebook_1_pane_4, wx.ID_ANY, _("Overwrite existing file"))
        self.checkbox_1.SetToolTipString(_("Overwrite an existing file"))
        self.checkbox_1.SetValue(1)
        grid_sizer_2.Add(self.checkbox_1, 0, wx.ALL | wx.EXPAND, 5)
        
        grid_sizer_2.Add((20, 20), 0, 0, 0)
        
        self.static_line_1 = wx.StaticLine(self, wx.ID_ANY)
        sizer_1.Add(self.static_line_1, 0, wx.ALL | wx.EXPAND, 5)
        
        sizer_2 = wx.FlexGridSizer(1, 3, 0, 0)
        sizer_1.Add(sizer_2, 0, wx.ALIGN_RIGHT, 0)
        
        self.button_5 = wx.Button(self, wx.ID_CLOSE, "")
        sizer_2.Add(self.button_5, 0, wx.ALIGN_RIGHT | wx.ALL, 5)
        
        self.button_2 = wx.Button(self, wx.ID_CANCEL, "", style=wx.BU_TOP)
        sizer_2.Add(self.button_2, 0, wx.ALIGN_RIGHT | wx.ALL, 5)
        
        self.button_1 = wx.Button(self, wx.ID_OK, "", style=wx.BU_TOP)
        sizer_2.Add(self.button_1, 0, wx.ALIGN_RIGHT | wx.ALL, 5)
        
        grid_sizer_2.AddGrowableCol(1)
        self.notebook_1_pane_4.SetSizer(grid_sizer_2)
        
        self.notebook_1_pane_3.SetSizer(sizer_3)
        
        self.notebook_1_pane_2.SetSizer(sizer_4)
        
        grid_sizer_1.AddGrowableCol(1)
        self.notebook_1_pane_1.SetSizer(grid_sizer_1)
        
        sizer_1.AddGrowableRow(0)
        sizer_1.AddGrowableCol(0)
        self.SetSizer(sizer_1)
        
        self.Layout()
        self.Centre()

        self.Bind(wx.EVT_BUTTON, self.startConverting, self.button_1)
        # end wxGlade

    def __set_properties(self):

        # manually added
        self.SetTitle(_("mp3 2 ogg - started at") + time.asctime())

    def __do_layout(self):

    def startConverting(self, event):  # wxGlade: PyOgg1_MyDialog.<event_handler>
        print("Event handler 'startConverting' not implemented!")
        event.Skip()

# end of class PyOgg1_MyDialog
if __name__ == "__main__":
    gettext.install("PyOgg1_app") # replace with the appropriate catalog name

    PyOgg1_app = wx.PySimpleApp()
    Mp3_To_Ogg = PyOgg1_MyDialog(None, wx.ID_ANY, "")
    PyOgg1_app.SetTopWindow(Mp3_To_Ogg)
    Mp3_To_Ogg.Show()
    PyOgg1_app.MainLoop()
Пример #18
0
def main():
    app = wx.PySimpleApp()
    image = Frame()
    image.Center()
    image.Show()
    app.MainLoop()
Пример #19
0
def make_gui():
    app = wx.PySimpleApp()
    root = wx.Frame(None, -1, 'Iplot')

    root_sizer = wx.BoxSizer(wx.VERTICAL)
    root.SetSizer(root_sizer)

    log_widget = wx.TextCtrl(root, -1, style=wx.TE_MULTILINE, size=(600, 600))

    root_sizer.Add(log_widget, 1, wx.ALL | wx.EXPAND)

    clear_id = wx.NewId()
    clear_button = wx.Button(root, clear_id, 'Clear Log Window')
    root.Bind(wx.EVT_BUTTON, lambda e: log_widget.Clear(), id=clear_id)
    root_sizer.Add(clear_button, 0, wx.RIGHT | wx.EXPAND)

    menubar = wx.MenuBar(style=wx.MENU_TEAROFF)

    file_menu = wx.Menu(style=wx.MENU_TEAROFF)

    file_new_id = wx.NewId()
    file_menu.Append(file_new_id, "&New")
    root.Bind(wx.EVT_MENU, lambda e: show_bootstrap_init(), id=file_new_id)

    file_save_id = wx.NewId()
    file_menu.Append(file_save_id, "&Save")
    root.Bind(wx.EVT_MENU, lambda e: save_data(), id=file_save_id)

    file_open_id = wx.NewId()
    file_menu.Append(file_open_id, "Open")
    root.Bind(wx.EVT_MENU, lambda e: open_data(), id=file_open_id)

    file_exit_id = wx.NewId()
    file_menu.Append(file_exit_id, "&Exit")
    root.Bind(wx.EVT_MENU, lambda e: sys.exit(0), id=file_exit_id)

    menubar.Append(file_menu, "&File")

    #for name, val in sorted(menu_items):
    #    main_menu.Append(val, name)
    root.SetMenuBar(menubar)

    def save_data():
        if not os.access('.data', os.R_OK):
            dlg = wx.MessageDialog(None, 'No data to save', \
                    style=wx.ICON_ERROR | wx.OK)
            dlg.ShowModal()
            return
        fdialog = wx.FileDialog(None, "Choose save file", os.getcwd(), \
                style=wx.SAVE, wildcard='*.zip')
        if fdialog.ShowModal() == wx.ID_OK:
            zipfilename = fdialog.GetFilename()
            zip = zipfile.ZipFile(str(zipfilename).rstrip('.zip') + '.zip', \
                    'w')
            for filename in os.listdir('.data'):
                zip.write(filename)
            zip.close()
        fdialog.Destroy()

    def open_data():
        log_msg('SORRY NOT IMPLEMENTED')
        return
        setup_data_dir()
        fdialog = wx.FileDialog(None, "Choose zipped file to open", \
                os.getcwd(), style=wx.OPEN, wildcard='*.zip')
        if fdialog.ShowModal() == wx.ID_OK:
            zipfilename = fdialog.GetFilename()
            zip = zipfile.ZipFile(str(zipfilename).rstrip('.zip') + '.zip', \
                    'r')
            for filename in zip.namelist():
                #os.makedirs(os.path.dirname(filename))
                file('.data/' + os.path.basename(filename), 'wb').write( \
                        zip.read(filename))
            zip.close()
            load_iplot(default_output_prefix)
        fdialog.Destroy()

    def log_msg(msg):
        t = datetime.datetime.now()
        log_widget.AppendText("%s: %s\n" % (str(t), msg))

    def to_wx_color(string_color):
        rgb = ColorConverter().to_rgb(string_color)
        return wx.Color(*[x * 255 for x in rgb])

    def to_mpl_color(wxcolor):
        return rgb2hex([float(x) / 255.0 for x in wxcolor.Get()])

    def show_plot(name, plot_args):
        pwin = wx.Frame(root, -1, name)

        #iplot.figure.clear() #delaxes(plot)
        figure = Figure(facecolor='#ffffff')
        plot = [gen_plot(figure, plot_args)]

        #iplot.figure.clear()
        #iplot.figure.add_axes(plot)

        frame_box = wx.BoxSizer(wx.VERTICAL)
        pwin.SetSizer(frame_box)

        graph_panel = wx.Panel(pwin, -1, style=wx.SUNKEN_BORDER)
        graph_vbox = wx.BoxSizer(wx.VERTICAL)
        graph_panel.SetSizer(graph_vbox)

        canvas = FigureCanvasWx(graph_panel, -1, figure)
        canvas.draw()
        graph_vbox.Add(canvas, 1, wx.ALL | wx.EXPAND)

        toolbar = NavigationToolbar2Wx(canvas)
        toolbar.Realize()
        graph_vbox.Add(toolbar, 0, wx.LEFT | wx.EXPAND)
        toolbar.update()

        edit_panel = wx.Panel(pwin, -1, style=wx.SUNKEN_BORDER)
        edit_box = wx.GridSizer(4, 2)
        edit_panel.SetSizer(edit_box)

        grid_items = []

        def make_entry(name, default=''):
            grid_items.append((wx.StaticText(edit_panel, -1, name), 0, 0))
            id = wx.NewId()
            entry = wx.TextCtrl(edit_panel, id, default)  #, size=(150, -1))
            grid_items.append((entry, 1, wx.RIGHT | wx.EXPAND))
            return entry

        def set_attributes(*args):
            try:
                if hasattr(plot[0], 'iplot_errorbar'):
                    loc = {}
                    try:
                        expression, initial = expr_entry.GetValue().split('@')
                        symbols, points = ifit.read_min_mean_max_file(
                            plot[0].filename)
                        fit=ifit.IFit(expression,points,symbols,\
                               condition=cond_entry.GetValue())
                        variables = ifit.restricted_eval(
                            'dict(%s)' % initial, loc)
                        variables, least_squares, hessian = fit.fit(
                            **variables)
                        fit.scatter_points = 0
                        if scatter_entry.GetValue():
                            fit.scatter_points = int(scatter_entry.GetValue())
                        if fit.scatter_points:
                            fit.iterative_fit(default_output_prefix \
                               + '_scatter.csv', **variables)
                        for key, value in variables.items():
                            log_msg('%s = %g' % (key, value))
                        log_msg('least_squares=%s' % least_squares)
                        log_msg('hessian=%s' % str(hessian))
                        bound_min, bound_max = \
                           plot[0].get_xaxis().get_data_interval().get_bounds()
                        if bound_min == bound_max:
                            return
                        new_ydata = []
                        new_xdata = numpy.arange(bound_min, bound_max, \
                               (bound_max - bound_min) / 200.0, numpy.float)
                        # str() to convert from unicode
                        #extrapolate_variable = str(extrap_entry.GetValue())
                        #if fit.scatter_points:
                        #    extrap = lambda f, c: fit.extrapolate_with_errors(**c)
                        #else:
                        #    extrap = lambda f, c: fit.extrapolate(**c)
                        #for item in new_xdata:
                        #    coordinates = {extrapolate_variable:item}
                        #    #coordinates=ifit.restricted_eval('dict(%s)' % item,loc)
                        #    e = extrap(fit, coordinates)
                        #    new_ydata.append(e)
                        #    print 'extrapolation %s -> %s' % (item,str(e))
                        #### replaced by
                        for item in new_xdata:
                            new_ydata.append(fit.f(**{IPlot.indices[0]: item}))
                        plot[0] = gen_plot(figure, plot_args)
                        if fit.scatter_points:
                            low, mid, high = [], [], []
                            for h, m, l in new_ydata:
                                low.append(l)
                                mid.append(m)
                                high.append(h)
                            plot[0].plot(new_xdata, low, color='#ff5555')
                            plot[0].plot(new_xdata, mid, color='#ff0000')
                            plot[0].plot(new_xdata, high, color='#bb0000')
                        else:
                            plot[0].plot(new_xdata, new_ydata, color='r')
                    except Exception, e:
                        log_msg(e)
                        log_msg('NO FIT')
                plot[0].set_xlabel(xlabel_entry.GetValue())
                plot[0].set_ylabel(ylabel_entry.GetValue())
                plot[0].set_title(title_entry.GetValue())
                plot[0].set_axis_bgcolor(background_entry.GetValue())
                figure.set_facecolor(background_entry.GetValue())
                canvas.draw()
            except Exception, e:
                traceback.print_tb(sys.exc_info()[2])
                dlg = wx.MessageDialog(None, 'Error setting preferences:\t' + \
                        str(e), style=wx.ICON_ERROR | wx.OK)
                dlg.ShowModal()
Пример #20
0
                    image = image[:, :(megapicture.shape[1] - offs[1]), :]
                megapicture[offs[0]:(offs[0]+image.shape[0]),
                            offs[1]:(offs[1]+image.shape[1]), :] += image
        self.axes.cla()
        self.axes.imshow(megapicture)
        self.canvas.draw()
        self.navtoolbar.update()

if __name__=="__main__":
    import os
    import re
    import bioformats
    import javabridge
    from cellprofiler.utilities.cpjvm import cp_start_vm
    cp_start_vm()
    app = wx.PySimpleApp(True)
    dlg = wx.Dialog(None, size=(1024, 768), 
                    style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.THICK_FRAME)
    data = PlateData()
    root = r"\\iodine-cifs\imaging_analysis\2007_09_24_BBBC_ImagingPlatform\Fibroblasts"
    paths = [pathname2url(os.path.join(root, filename))
             for filename in os.listdir(root)
             if filename.startswith("plate")]
    filenames = []
    plates = []
    wells = []
    sites = []
    channels = []
    # example file name: HDFa030510P6hiP6loP20hiP20lo_A11_s1_w2E387A0AC-E9DE-42FA-8BBC-73F9BA938085.tif
    pattern = "^(?P<Plate>.+)_(?P<Well>[A-P][0-9]{2})_(?P<Site>s[0-9])_(?P<Channel>w[0-9])[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}.tif$"
    for path in paths:
Пример #21
0
def test():
    cnblogsFan = wx.PySimpleApp()
    mainFrame = MainFrame()
    mainFrame.Show()
    cnblogsFan.MainLoop()
def main():
    app = wx.PySimpleApp()
    frame = TestFrame(None, -1, 'BoxSizer Demos')
    frame.Show(True)
    app.MainLoop()
Пример #23
0
 def setUp(self):
     self.app = wx.PySimpleApp()
     self.frame = wx.Frame(parent=None, id=wx.ID_ANY)
     self.testControl = wx.Choice(parent=self.frame)
Пример #24
0
def main():
    app = wx.PySimpleApp()
    frame = LauncherFrame()
    frame.Show()
    app.MainLoop()
Пример #25
0
                #see if getter breaks
                getter = getattr(obj, getname).im_func
                v = getter(obj)
                result = ('Properties', property, getter, func)
        except Exception, err:
            pass
    return result


def traverseAndBuildProps(props, vetoes, obj, Class):
    for m in Class.__dict__.keys():
        if m not in vetoes:
            cat, name, methGetter, methSetter = \
              getMethodType(m, obj, Class.__dict__)

            if not props[cat].has_key(name):
                props[cat][name] = (methGetter, methSetter)

    for Cls in Class.__bases__:
        traverseAndBuildProps(props, vetoes, obj, Cls)


if __name__ == '__main__':
    wx.PySimpleApp()
    f = wx.Frame(None, -1, 'asd')
    c = wx.ComboBox(f, -1)
    props = {'Properties': {}, 'Built-ins': {}, 'Methods': {}}
    traverseAndBuildProps(props, [], c, c.__class__)
    import pprint
    pprint.pprint(props)
Пример #26
0
def main():
    app = wx.PySimpleApp()
    frame = wx.Frame(None,-1,'ball_wx',wx.DefaultPosition,wx.Size(400,400))
    canvas = LMGLCanvas(frame)
    frame.Show()
    app.MainLoop()
        t = self.N.Value
        t = t.replace("x",",")
        try: grid.n = asarray(eval(t))
        except Exception,msg: print("%r: %r" % (t,msg))        
        t = self.Origin.Value
        try: grid.origin = asarray(eval(t))
        except Exception,msg: print("%r: %r" % (t,msg))        
        t = self.BaseVectors.Value
        t = t.replace("\r","\n")
        try: grid.base_vectors = asarray([eval(v) for v in t.split("\n")])
        except Exception,msg: print("%r: %r" % (v,msg))
        ##print("grid.n = %r" % n)
        ##print("grid.origin = %r" % origin)
        ##print("grid.base_vectors = %r" % base_vectors)
        self.update()
       

def tofloat(x):
    from numpy import nan
    try: return float(x)
    except: return nan



if __name__ == '__main__': # for testing
    from pdb import pm
    app = wx.PySimpleApp(redirect=False) # Needed to initialize WX library
    window = SampleTranslationRasterPanel()
    app.MainLoop()
    self = window # for debugging
Пример #28
0
 def configure_context(self):
     from peak.events.activity import EventLoop, WXEventLoop
     EventLoop <<= WXEventLoop
     self.app = wx.PySimpleApp(redirect=False)
     self.frame = wx.Frame(None)
Пример #29
0
        sizer_3.Add(self.dataTypeChoice, 1, wx.ALIGN_CENTER_VERTICAL, 0)
        sizer_2.Add(sizer_3, 0, wx.BOTTOM|wx.EXPAND, 4)
        sizer_7.Add(self.endiannessRadioBox, 1, wx.EXPAND, 0)
        sizer_2.Add(sizer_7, 0, wx.BOTTOM|wx.EXPAND, 4)
        sizer_5.Add(sizer_2, 1, wx.ALL|wx.EXPAND, 7)
        grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.headerSizeText, 0, wx.EXPAND, 0)
        grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.extentText, 0, wx.EXPAND, 0)
        grid_sizer_1.Add(self.label_5, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_1.Add(self.spacingText, 0, wx.EXPAND, 0)
        grid_sizer_1.AddGrowableCol(1)
        sizer_5.Add(grid_sizer_1, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 7)
        self.viewFramePanel.SetSizer(sizer_5)
        sizer_1.Add(self.viewFramePanel, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()
        # end wxGlade

# end of class rawVolumeRDRViewFrame


if __name__ == "__main__":
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = rawVolumeRDRViewFrame(None, -1, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
    app.MainLoop()
Пример #30
0
def main():
    app = wx.PySimpleApp()
    MyForm().Show()
    app.MainLoop()