Esempio n. 1
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          title='Snapshot Printer',
                          size=(650, 400))

        self.panel = wx.Panel(self)
        self.printer = HtmlEasyPrinting(name='Printing', parentWindow=None)

        self.html = HtmlWindow(self.panel)
        self.html.SetRelatedFrame(self, self.GetTitle())

        if not os.path.exists('screenshot.htm'):
            self.createHtml()
        self.html.LoadPage('screenshot.htm')

        pageSetupBtn = wx.Button(self.panel, label='page setup')
        printBtn = wx.Button(self.panel, label='Print')
        cancelBtn = wx.Button(self.panel, label='Cancel')

        self.Bind(wx.EVT_BUTTON, self.onSetup, pageSetupBtn)
        self.Bind(wx.EVT_BUTTON, self.onPrint, printBtn)
        self.Bind(wx.EVT_BUTTON, self.onCancel, cancelBtn)

        sizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)

        sizer.Add(self.html, 1, wx.GROW)
        btnSizer.Add(pageSetupBtn, 0, wx.ALL, 5)
        btnSizer.Add(printBtn, 0, wx.ALL, 5)
        btnSizer.Add(cancelBtn, 0, wx.ALL, 5)
        sizer.Add(btnSizer)

        self.panel.SetSizer(sizer)
        self.panel.SetAutoLayout(True)
Esempio n. 2
0
class Plot_info(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)
        self.SetIcon(parent.GetParent().GetIcon())
        self.html = HtmlWindow(self, style=wx.html.HW_SCROLLBAR_AUTO)
        if "gtk2" in wx.PlatformInfo:
            self.html.SetStandardFonts()
        self.Bind(wx.EVT_CLOSE, self.on_window_close)
        self.__alive = False

    def set_infotext(self, text, title=""):
        self.SetTitle(
            _("%(a)s: Plot info (%(b)s)") % {
                'a': PROG_NAME,
                'b': title
            })
        self.html.SetPage(wiki2html(text))
        self.__alive = True
        self.Show(True)
        self.Raise()

    def __nonzero__(self):
        return self.__alive

    def on_window_close(self, evt=None):
        "closing and making self False"
        del self.html
        self.Destroy()
        self.__alive = False
Esempio n. 3
0
    def _InitUI(self):
        """Builds this UI component.  Obviously, must be called in the UI thread.
"""
        #		-- Header
        #		--
        self.headerCtrl = wx.TextCtrl(self,
                                      wx.ID_ANY,
                                      style=wx.BORDER_NONE | wx.TE_DONTWRAP
                                      | wx.TE_READONLY)
        self.headerCtrl.SetBackgroundColour(self.GetBackgroundColour())

        #		-- View
        #		--
        if WEB_VIEW:
            self.webView = WebView.New(self)
            self.webView.SetBackgroundColour(self.GetBackgroundColour())
        else:
            self.webView = HtmlWindow(self)

#		-- Lay Out
#		--
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(
            self.headerCtrl, 0,
            wx.ALIGN_CENTRE_VERTICAL | wx.ALIGN_LEFT | wx.ALL | wx.EXPAND, 2)
        sizer.Add(self.webView, 1,
                  wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_TOP | wx.EXPAND, 4)
        self.SetAutoLayout(True)
        self.SetSizer(sizer)

        #		-- Events
        #		--
        self.Bind(wx.EVT_CONTEXT_MENU, self._OnContextMenu)
Esempio n. 4
0
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self,
                           id=wxID_ABOUTDIALOG,
                           name=u'AboutDialog',
                           parent=prnt,
                           pos=wx.Point(120, 93),
                           size=wx.Size(304, 344),
                           style=wx.DEFAULT_DIALOG_STYLE,
                           title=u'About crontab.txt Editor')
        self.SetClientSize(wx.Size(296, 317))

        self.OKButton = wx.Button(id=wxID_ABOUTDIALOGOKBUTTON,
                                  label=u'&OK',
                                  name=u'OKButton',
                                  parent=self,
                                  pos=wx.Point(108, 280),
                                  size=wx.Size(80, 24),
                                  style=0)
        wx.EVT_BUTTON(self.OKButton, wxID_ABOUTDIALOGOKBUTTON,
                      self.OnOkbuttonButton)

        self.aboutHtmlWindow = HtmlWindow(id=wxID_ABOUTDIALOGABOUTHTMLWINDOW,
                                          name=u'aboutHtmlWindow',
                                          parent=self,
                                          pos=wx.Point(8, 8),
                                          size=wx.Size(280, 256))
class SnapshotPrinter(wx.Frame):
    def __init__(self, title='Snapshot Printer'):
        wx.Frame.__init__(self, None, title=title, size=(650, 400))

        self.panel = wx.Panel(self)
        self.printer = HtmlEasyPrinting(name='Printing', parentWindow=None)

        self.html = HtmlWindow(self.panel)
        self.html.SetRelatedFrame(self, self.GetTitle())

        if not os.path.exists('screenshot.htm'):
            self.createHtml()
        self.html.LoadPage('screenshot.htm')

        pageSetupBtn = wx.Button(self.panel, label='Page Setup')
        printBtn = wx.Button(self.panel, label='Print')
        cancelBtn = wx.Button(self.panel, label='Cancel')

        self.Bind(wx.EVT_BUTTON, self.onSetup, pageSetupBtn)
        self.Bind(wx.EVT_BUTTON, self.onPrint, printBtn)
        self.Bind(wx.EVT_BUTTON, self.onCancel, cancelBtn)

        sizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)

        sizer.Add(self.html, 1, wx.GROW)
        btnSizer.Add(pageSetupBtn, 0, wx.ALL, 5)
        btnSizer.Add(printBtn, 0, wx.ALL, 5)
        btnSizer.Add(cancelBtn, 0, wx.ALL, 5)
        sizer.Add(btnSizer)

        self.panel.SetSizer(sizer)
        self.panel.SetAutoLayout(True)

    def createHtml(self):
        '''
        Creates an html file in the home directory of the application
        that contains the information to display the snapshot
        '''
        print('creating html...')

        html = '''<html>\n<body>\n<center>
        <img src=myImage.png width=516 height=314>
        </center>\n</body>\n</html>'''
        with open('screenshot.htm', 'w') as fobj:
            fobj.write(html)

    def onSetup(self, event):
        self.printer.PageSetup()

    def onPrint(self, event):
        self.sendToPrinter()

    def sendToPrinter(self):
        self.printer.GetPrintData().SetPaperId(wx.PAPER_LETTER)
        self.printer.PrintFile(self.html.GetOpenedPage())

    def onCancel(self, event):
        self.Close()
Esempio n. 6
0
 def __init__(self, parent):
     wx.Frame.__init__(self, parent)
     self.SetIcon(parent.GetParent().GetIcon())
     self.html = HtmlWindow(self, style=wx.html.HW_SCROLLBAR_AUTO)
     if "gtk2" in wx.PlatformInfo:
         self.html.SetStandardFonts()
     self.Bind(wx.EVT_CLOSE, self.on_window_close)
     self.__alive = False
Esempio n. 7
0
 def __init__(self, parent, title):
     super(MyHtmlFrame, self).__init__(parent)
     html = HtmlWindow(parent=self)
     if "gtk2" in wx.PlatformInfo:
         html.SetStandardFonts()
     wx.CallAfter(
         html.LoadPage,
         os.path.join("../../../src/", "dialogs/HelpWindow.html"))
Esempio n. 8
0
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)
        document = open('document.md', 'r')

        html = markdown.markdown(document.read())  # Read the whole file

        self.html_window = HtmlWindow(self)
        self.html_window.SetPage(html)

        self.Show()
 def onHelpMenu(self, evt):
     if self.help:
         n = self.tab.GetPageCount()
         self.tab.SetSelection(n - 1)
     else:
         self.help = HtmlWindow(self.tab, -1)
         self.help.LoadFile("resources/intro.html")
         n = self.tab.GetPageCount()
         self.tab.InsertPage(n, self.help, "Welcome")
         self.tab.SetSelection(n)
Esempio n. 10
0
    def __init__(self, parent, ID, title):
        """
        Constructor.

        @since 1.0
        @author C.Dutoit
        """
        # dialog box
        super().__init__(parent, ID, title, DefaultPosition, Size(720, 520))

        self.Center(BOTH)

        self.html = HtmlWindow(self, -1, DefaultPosition, Size(720, 520))

        htmlFileName = resource_filename(DlgHelp.HELP_PKG_NAME, 'index.html')
        self.html.LoadPage(htmlFileName)

        self.printer = HtmlEasyPrinting()

        self.box = BoxSizer(VERTICAL)
        self.box.Add(self.html, 1, GROW)
        subbox = BoxSizer(HORIZONTAL)

        btn = Button(self, ID_BACK, _("Back"))
        self.Bind(EVT_BUTTON, self.__OnBack, id=ID_BACK)
        subbox.Add(btn, 1, GROW | ALL, 2)

        btn = Button(self, ID_FORWARD, _("Forward"))
        self.Bind(EVT_BUTTON, self.__OnForward, id=ID_FORWARD)
        subbox.Add(btn, 1, GROW | ALL, 2)

        btn = Button(self, ID_PRINT, _("Print"))
        self.Bind(EVT_BUTTON, self.__OnPrint, id=ID_PRINT)
        subbox.Add(btn, 1, GROW | ALL, 2)

        btn = Button(self, ID_VIEW_SOURCE, _("View Source"))
        self.Bind(EVT_BUTTON, self.__OnViewSource, id=ID_VIEW_SOURCE)
        subbox.Add(btn, 1, GROW | ALL, 2)

        btn = Button(self, ID_OK, _("Exit"))
        subbox.Add(btn, 1, GROW | ALL, 2)

        self.box.Add(subbox, 0, GROW | BOTTOM)
        self.SetSizer(self.box)
        self.SetAutoLayout(True)
        subbox.Fit(self)
        self.box.Fit(self)

        self.OnShowDefault(None)

        self.Show(True)
Esempio n. 11
0
class MarkdownWindow(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT)
        self.html_window = HtmlWindow(self)
        self.Show()

    def read_markdown_file(self, file_path):
        document = open(file_path, 'r')
        html = markdown.markdown(document.read())
        self.html_window.SetPage(html)

    def read_markdown_text(self, text):
        html = markdown.markdown(text)
        self.html_window.SetPage(html)
Esempio n. 12
0
    def CreateCtrls(self):
        """
        Make widgets for my application.
        """

        font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
        font.SetWeight(wx.BOLD)
        font.SetPointSize(10)

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

        # First create the controls.
        self.panel = wx.Panel(self,
                              id=-1,
                              style=wx.BORDER_THEME | wx.TAB_TRAVERSAL)

        self.demo = wx.StaticText(self.panel, id=-1, label="Demonstrating :")
        self.demo.SetFont(font)

        self.winHtml = HtmlWindow(self.panel,
                                  id=-1,
                                  style=wx.BORDER_THEME
                                  | wx.NO_FULL_REPAINT_ON_RESIZE)
        self.winHtml.SetPage(sample_html)

        self.info = wx.StaticText(self.panel,
                                  id=-1,
                                  label="1) Direct printing,\n"
                                  "2) HtmlWindow,\n"
                                  "3) HtmlEasyPrinting class,\n"
                                  "4) Preview,\n"
                                  "5) Menu,\n"
                                  "6) Page setup.")
        self.info.SetForegroundColour("red")
        font.SetWeight(wx.NORMAL)
        self.info.SetFont(font)

        self.btnSetup = wx.Button(self.panel,
                                  id=wx.ID_PAGE_SETUP,
                                  label="Page set&up")

        self.btnPreview = wx.Button(self.panel,
                                    wx.ID_PREVIEW,
                                    label="Pre&view text")
        self.btnPreview.SetFocus()

        self.btnPrint = wx.Button(self.panel, id=wx.ID_PRINT, label="&Print")

        self.btnClose = wx.Button(self.panel, id=wx.ID_CLOSE, label="E&xit")
Esempio n. 13
0
    def about(self, evt: wx.MenuEvent):
        with wx.Dialog(self) as dialog:

            def on_link_clicked(evt: wx.html.HtmlLinkEvent):
                print(f"CLicked on URL: {evt.GetLinkInfo().GetHref()}")
                os.startfile(evt.GetLinkInfo().GetHref())

            dialog: wx.Dialog

            richtext = HtmlWindow(dialog, size=(150, 150))
            richtext.Bind(wx.html.EVT_HTML_LINK_CLICKED, on_link_clicked)
            richtext.SetPage(
                f"<center style='font-family: \"Malgun Gothic Semilight\";font-size: 26'>"
                f"NZT Explorer"
                f"</center>"
                f"<center style='font-family: \"Malgun Gothic Semilight\";font-size: 12'>"
                f"<br><br>Version: {VERSION}"
                f"</center>"
                f"<center style='font-family: \"Malgun Gothic Semilight\";font-size: 12'>"
                f"<br>Website: "
                f"<a href='https://quintenjungblut.wixsite.com/qplaysoftware'>"
                f"https://quintenjungblut.wixsite.com/qplaysoftware"
                f"</a>")

            main_button = wx.Button(self, id=wx.ID_OK, label="OK")
            dialog.AddMainButtonId(wx.ID_OK)

            dialog.ShowModal()
Esempio n. 14
0
    def _createHTMLPanel(self, sizedPanel: SizedPanel):

        htmlPanel: SizedPanel = SizedPanel(parent=sizedPanel, id=ID_ANY)
        htmlPanel.SetSizerType('horizontal')

        # noinspection PyUnresolvedReferences
        htmlPanel.SetSizerProps(expand=True)

        htmlSize: Size = Size(width=440, height=128)
        self._html = HtmlWindow(parent=htmlPanel,
                                id=ID_ANY,
                                size=htmlSize,
                                style=NO_FULL_REPAINT_ON_RESIZE)

        helpText: str = Resources.retrieveResourceText(
            ResourceTextType.SIMPLE_HELP)
        self._html.SetPage(helpText)
Esempio n. 15
0
    def __init__(self,
                 parent,
                 id=-1,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=HW_DEFAULT_STYLE,
                 name="htmlWindow"):
        wxHtmlWindow.__init__(self, parent, id, pos, size, style, name)
        self.SetForegroundColour(parent.GetForegroundColour())
        self.SetBackgroundColour(parent.GetBackgroundColour())

        if wx.html.HW_NO_SELECTION & style:
            self.Bind(wx.EVT_MOTION, self.OnIdle)
            self.handCursor = wx.StockCursor(wx.CURSOR_HAND)
            self.x1, self.y1 = self.GetScrollPixelsPerUnit()
            self.isSet = False
        self.Bind(EVT_HTML_LINK_CLICKED, self.OnHtmlLinkClicked)
Esempio n. 16
0
 def SetPage(self, html):
     pos = html.find("<rst>")
     if pos != -1:
         html = DecodeReST(html[pos + 5:])
     wxHtmlWindow.SetPage(
         self, '<html><body bgcolor="%s" text="%s">%s</body></html>' %
         (self.GetBackgroundColour().GetAsString(wx.C2S_HTML_SYNTAX),
          self.GetForegroundColour().GetAsString(wx.C2S_HTML_SYNTAX), html))
Esempio n. 17
0
    def __init__(self, parent):
        wx.Dialog.__init__(self, parent, -1, u'软件帮助',
                          size=(550, 495))

        html = HtmlWindow(self)
        html.SetPage(self.text2);
        self.Centre();
        self.icon = wx.Icon('icon.ico', wx.BITMAP_TYPE_ICO);
        self.SetIcon(self.icon);
        button = wx.Button(self, wx.ID_OK, u"已知晓")

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(html, 1, wx.EXPAND|wx.ALL, 5)
        sizer.Add(button, 0, wx.ALIGN_CENTER|wx.ALL, 5)

        self.SetSizer(sizer)
        self.Layout()
Esempio n. 18
0
 def SetPage(self, html):
     if html.startswith("<md>"):
         html = DecodeMarkdown(html[4:])
     elif html.startswith("<rst>"):
         html = DecodeReST(html[5:])
     wxHtmlWindow.SetPage(
         self, '<html><body bgcolor="%s" text="%s">%s</body></html>' %
         (self.GetBackgroundColour().GetAsString(wx.C2S_HTML_SYNTAX),
          self.GetForegroundColour().GetAsString(wx.C2S_HTML_SYNTAX), html))
Esempio n. 19
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: QuickInfoFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.view_frame_panel = wx.Panel(self, -1)
        self.output_html = HtmlWindow(self.view_frame_panel, -1)

        self.__set_properties()
        self.__do_layout()
Esempio n. 20
0
    def __init__(
        self,
        parent,
        id=-1,
        pos=wx.DefaultPosition,
        size=wx.DefaultSize,
        style=HW_DEFAULT_STYLE,
        name="htmlWindow"
    ):
        wxHtmlWindow.__init__(self, parent, id, pos, size, style, name)
        self.SetForegroundColour(parent.GetForegroundColour())
        self.SetBackgroundColour(parent.GetBackgroundColour())

        #if wx.html.HW_NO_SELECTION & style:
        #    self.Bind(wx.EVT_MOTION, self.OnIdle)
        #    self.handCursor = wx.StockCursor(wx.CURSOR_HAND)
        #    self.x1, self.y1 = self.GetScrollPixelsPerUnit()
        #    self.isSet = False
        self.Bind(EVT_HTML_LINK_CLICKED, self.OnHtmlLinkClicked)
Esempio n. 21
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: htmlWindowFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.panel_1 = wx.Panel(self, -1)
        self.htmlWindow = HtmlWindow(self.panel_1, -1)
        self.closeButtonId = wx.NewId()
        self.closeButton = wx.Button(self.panel_1, self.closeButtonId, "Close")

        self.__set_properties()
        self.__do_layout()
Esempio n. 22
0
    def __init__(self, parent, size):
        HtmlWindow.__init__(self,
                            parent,
                            ID_ANY,
                            DefaultPosition,
                            size=size,
                            style=html.HW_SCROLLBAR_AUTO)
        params = {"version": Settings.version()}
        self.SetPage(u"""
<!doctype html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>关于</title>
</head>
<body>
<h1>mHosts %(version)s</h1>
<h4>免费好用的跨平台Hosts管理工具</h4>
<table style="width:100%%">
<tr>
    <td style='text-align: right;'>作者:</td>
    <td><a href="https://hefang.link/?from=mHostsv%(version)s" title="点击访问何方博客">何方</a></td>
</tr>
<tr>
    <td style='text-align: right;'>项目地址:</td>
    <td>
        <a href="https://github.com/iamhefang/mHosts">https://github.com/iamhefang/mHosts</a>
    </td>
</tr>
<tr>
    <td style='text-align: right;'>问题和建议:</td>
    <td>
        <a href="https://github.com/iamhefang/mHosts/issues">Issues</a>
    </td>
</tr>
</table>
</body>
</html>""" % params)
Esempio n. 23
0
File: ghelp.py Progetto: caomw/grass
    def __init__(self, parent, command, text, skipDescription,
                 **kwargs):
        """If command is given, the corresponding HTML help
        file will be presented, with all links pointing to absolute
        paths of local files.

        If 'skipDescription' is True, the HTML corresponding to
        SYNOPSIS will be skipped, thus only presenting the help file
        from the DESCRIPTION section onwards.

        If 'text' is given, it must be the HTML text to be presented
        in the Panel.
        """
        self.parent = parent
        if not globalvar.CheckWxVersion([2, 9]):
            wx.InitAllImageHandlers()
        HtmlWindow.__init__(self, parent = parent, **kwargs)
        
        self.loaded = False
        self.history = list()
        self.historyIdx = 0
        self.fspath = os.path.join(os.getenv("GISBASE"), "docs", "html")
        
        self.SetStandardFonts (size = 10)
        self.SetBorders(10)
        
        if text is None:
            if skipDescription:
                url = os.path.join(self.fspath, command + ".html")
                self.fillContentsFromFile(url,
                                          skipDescription = skipDescription)
                self.history.append(url)
                self.loaded = True
            else:
                ### FIXME: calling LoadPage() is strangely time-consuming (only first call)
                # self.LoadPage(self.fspath + command + ".html")
                self.loaded = False
        else:
            self.SetPage(text)
            self.loaded = True
Esempio n. 24
0
    def __init__(self, parent, command, text, skipDescription,
                 **kwargs):
        """If command is given, the corresponding HTML help
        file will be presented, with all links pointing to absolute
        paths of local files.

        If 'skipDescription' is True, the HTML corresponding to
        SYNOPSIS will be skipped, thus only presenting the help file
        from the DESCRIPTION section onwards.

        If 'text' is given, it must be the HTML text to be presented
        in the Panel.
        """
        self.parent = parent
        if not globalvar.CheckWxVersion([2, 9]):
            wx.InitAllImageHandlers()
        HtmlWindow.__init__(self, parent=parent, **kwargs)

        self.loaded = False
        self.history = list()
        self.historyIdx = 0
        self.fspath = os.path.join(os.getenv("GISBASE"), "docs", "html")

        self.SetStandardFonts(size=10)
        self.SetBorders(10)

        if text is None:
            if skipDescription:
                url = os.path.join(self.fspath, command + ".html")
                self.fillContentsFromFile(url,
                                          skipDescription=skipDescription)
                self.history.append(url)
                self.loaded = True
            else:
                # FIXME: calling LoadPage() is strangely time-consuming (only first call)
                # self.LoadPage(self.fspath + command + ".html")
                self.loaded = False
        else:
            self.SetPage(text)
            self.loaded = True
Esempio n. 25
0
    def __init__(self, session):
        self.session = session

        from ..tool_api import ToolWindow
        self._scenes_window = ToolWindow("Scenes", "General", session,
            destroy_hides=True)
        #from wx.html2 import WebView, EVT_WEBVIEW_NAVIGATING, EVT_WEBVIEW_ERROR
        #self._scenes = WebView.New(self._scenes_window.ui_area, size=(700, 200))
        from wx.html import HtmlWindow, EVT_HTML_LINK_CLICKED
        self._scenes = HtmlWindow(self._scenes_window.ui_area, size=(700, 200))
        self._scenes.SetHTMLBackgroundColour(wx.Colour(0,0,0))
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self._scenes, 1, wx.EXPAND)
        self._scenes_window.ui_area.SetSizerAndFit(sizer)
        self._scenes_window.manage("top")
        self._scenes_window.shown = False
        #self._scenes.Bind(EVT_WEBVIEW_NAVIGATING,
        #    self.OnWebViewNavigating, self._scenes)
        #self._scenes.Bind(EVT_WEBVIEW_ERROR,
        #    self.OnWebViewError, self._scenes)
        wx.FileSystem.AddHandler(wx.MemoryFSHandler())
        #self._scenes.RegisterHandler(wx.MemoryFSHandler())
        self._scenes.Bind(EVT_HTML_LINK_CLICKED, self.OnHtmlLinkClicked)
        self.memory_files = []
Esempio n. 26
0
 def __init__(self, parent, style = 0, size = None, handler = None, pos = None):
     id = wx.ID_ANY
     name = u"ZHTMLControl" #$NON-NLS-1$
     self.handler = handler
     if size and pos:
         HtmlWindow.__init__(self, parent=parent, id=id, name=name, style=style, size=size, pos=pos)
     elif size:
         HtmlWindow.__init__(self, parent=parent, id=id, name=name, style=style, size=size)
     else:
         HtmlWindow.__init__(self, parent=parent, id=id, name=name, style=style)
Esempio n. 27
0
 def __init__(self):
     wx.Dialog.__init__(self, None, -1, "About <<project>>",
         style=wx.DEFAULT_DIALOG_STYLE | wx.THICK_FRAME | wx.RESIZE_BORDER |
             wx.TAB_TRAVERSAL)
     hwin = HtmlWindow(self, -1, size=(600, 400))
     vers = {}
     vers["python"] = sys.version.split()[0]
     vers["wxpy"] = wx.VERSION_STRING
     hwin.SetPage(aboutText % vers)
     btn = hwin.FindWindowById(wx.ID_OK)
     irep = hwin.GetInternalRepresentation()
     hwin.SetSize((irep.GetWidth() + 25, irep.GetHeight() + 10))
     self.SetClientSize(hwin.GetSize())
     self.CentreOnParent(wx.BOTH)
     self.SetFocus()
Esempio n. 28
0
class DlgHelp(SizedDialog):
    def __init__(self, parent: Window, wxID: int = wxNewIdRef()):

        super().__init__(parent,
                         wxID,
                         'Helpful Hints',
                         style=DEFAULT_DIALOG_STYLE)

        self.Center(BOTH)
        pane: SizedPanel = self.GetContentsPane()
        pane.SetSizerType('horizontal')
        self._createHTMLPanel(sizedPanel=pane)
        self.SetButtonSizer(self.CreateStdDialogButtonSizer(OK))

        self.Fit()
        self.SetMinSize(self.GetSize())

        self.Bind(EVT_BUTTON, self.__onCmdOk, id=ID_OK)
        self.Bind(EVT_CLOSE, self.__onCmdOk)

    def _createHTMLPanel(self, sizedPanel: SizedPanel):

        htmlPanel: SizedPanel = SizedPanel(parent=sizedPanel, id=ID_ANY)
        htmlPanel.SetSizerType('horizontal')

        # noinspection PyUnresolvedReferences
        htmlPanel.SetSizerProps(expand=True)

        htmlSize: Size = Size(width=440, height=128)
        self._html = HtmlWindow(parent=htmlPanel,
                                id=ID_ANY,
                                size=htmlSize,
                                style=NO_FULL_REPAINT_ON_RESIZE)

        helpText: str = Resources.retrieveResourceText(
            ResourceTextType.SIMPLE_HELP)
        self._html.SetPage(helpText)

    def __onCmdOk(self, event: CommandEvent):
        event.Skip(skip=True)
        self.SetReturnCode(OK)
        self.EndModal(OK)
Esempio n. 29
0
class AboutDialog(wx.Dialog):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self,
                           id=wxID_ABOUTDIALOG,
                           name=u'AboutDialog',
                           parent=prnt,
                           pos=wx.Point(120, 93),
                           size=wx.Size(304, 344),
                           style=wx.DEFAULT_DIALOG_STYLE,
                           title=u'About crontab.txt Editor')
        self.SetClientSize(wx.Size(296, 317))

        self.OKButton = wx.Button(id=wxID_ABOUTDIALOGOKBUTTON,
                                  label=u'&OK',
                                  name=u'OKButton',
                                  parent=self,
                                  pos=wx.Point(108, 280),
                                  size=wx.Size(80, 24),
                                  style=0)
        wx.EVT_BUTTON(self.OKButton, wxID_ABOUTDIALOGOKBUTTON,
                      self.OnOkbuttonButton)

        self.aboutHtmlWindow = HtmlWindow(id=wxID_ABOUTDIALOGABOUTHTMLWINDOW,
                                          name=u'aboutHtmlWindow',
                                          parent=self,
                                          pos=wx.Point(8, 8),
                                          size=wx.Size(280, 256))

    def __init__(self, parent):
        self._init_ctrls(parent)
        prgpath = os.path.dirname(os.path.abspath(sys.argv[0]))
        fileName = prgpath + os.sep + "about.html"
        self.aboutHtmlWindow.LoadFile(fileName)

    def OnOkbuttonButton(self, event):
        self.Close()
Esempio n. 30
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: MainFrameBase.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.splitterWindow = wx.SplitterWindow(self,
                                                -1,
                                                style=wx.SP_3D | wx.SP_BORDER)
        self.mainNotebook = wx.Notebook(self.splitterWindow,
                                        -1,
                                        style=wx.NB_BOTTOM)
        self.notebookSourcePanel = wx.Panel(self.mainNotebook, -1)
        self.notebookPreviewPanel = wx.Panel(self.mainNotebook, -1)
        self.leftPanel = wx.Panel(self.splitterWindow, -1)

        # Menu Bar
        self.menubar = wx.MenuBar()
        wxglade_tmp_menu = wx.Menu()
        self.menuOpen = wx.MenuItem(wxglade_tmp_menu, wx.NewId(),
                                    _("&Open...\tCTRL-O"), "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendItem(self.menuOpen)
        wxglade_tmp_menu.AppendSeparator()
        self.menuQuit = wx.MenuItem(wxglade_tmp_menu, wx.NewId(),
                                    _("Quit\tCTRL-Q"), "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendItem(self.menuQuit)
        self.menubar.Append(wxglade_tmp_menu, _("&File"))
        wxglade_tmp_menu = wx.Menu()
        self.menuCopy = wx.MenuItem(wxglade_tmp_menu, wx.NewId(),
                                    _("&Copy\tCTRL-C"), "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendItem(self.menuCopy)
        wxglade_tmp_menu.AppendSeparator()
        self.menuFind = wx.MenuItem(wxglade_tmp_menu, wx.NewId(),
                                    _("&Find...\tCTRL-F"), "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendItem(self.menuFind)
        self.menubar.Append(wxglade_tmp_menu, _("&Edit"))
        wxglade_tmp_menu = wx.Menu()
        self.menuAbout = wx.MenuItem(wxglade_tmp_menu, wx.NewId(),
                                     _("&About..."), "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendItem(self.menuAbout)
        self.menubar.Append(wxglade_tmp_menu, _("&Help"))
        self.SetMenuBar(self.menubar)
        # Menu Bar end
        self.searchCtrl = wx.TextCtrl(self.leftPanel, -1, "")
        self.titleList = wx.ListBox(self.leftPanel,
                                    -1,
                                    choices=[],
                                    style=wx.LB_SINGLE)
        self.previewCtrl = HtmlWindow(self.notebookPreviewPanel, -1)
        self.sourceCtrl = wx.TextCtrl(self.notebookSourcePanel,
                                      -1,
                                      "",
                                      style=wx.TE_MULTILINE | wx.TE_READONLY
                                      | wx.TE_RICH2)

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_MENU, self.menuOpenHandler, self.menuOpen)
        self.Bind(wx.EVT_MENU, self.menuQuitHandler, self.menuQuit)
        self.Bind(wx.EVT_MENU, self.menuCopyHandler, self.menuCopy)
        self.Bind(wx.EVT_MENU, self.menuFindHandler, self.menuFind)
        self.Bind(wx.EVT_MENU, self.menuAboutHandler, self.menuAbout)
        self.Bind(wx.EVT_TEXT, self.searchCtrlTextHandler, self.searchCtrl)
        self.Bind(wx.EVT_LISTBOX, self.titleListHandler, self.titleList)
Esempio n. 31
0
class DataAnalysisView(Widget):
    """Table widget.
"""

    DATA_HTML = """
<header>
<style type="text/css">
body {{ background-color: #f1f1f1 }}
p.title
  {{
  /*font-size: 12pt;*/
  font-style: italic;
  /*font-weight: bold;*/
  margin-bottom: 0 0 0 0.25em;
  text-decoration: underline;
  }}
table.data
  {{
  border: 1px solid black;
  border-collapse: collapse;
  margin: 0;
  }}
table.data tr
  {{
  border-bottom: 1px solid gray;
  vertical-align: top;
  }}
table.data tr th
  {{
  background-color: #c9c9c9;
  border: 1px solid gray;
  font-weight: normal; /*bold*/
  padding: 0.25em 0.5em 0.25em 0.5em;
  text-align: left;
  }}
table.data tr td
  {{
  /*border: 1px dotted gray;*/
  border-right: 1px dotted gray;
  font-weight: normal;
  padding: 0.1em 0.5em 0.1em 0.5em;
  text-align: left;
  }}
</style>
</header>
<body>
{table}
</body>
"""

    DATA_TABLE = """
<table class="data">
  <theader>{header}
  </theader>
  <tbody>{rows}
  </tbody>
</table>
"""

    DATA_TABLE_HTML_VIEW = """
<table class="data" border="1" cellpadding="4" cellspacing="0">
  <theader>{header}
  </theader>
  <tbody>{rows}
  </tbody>
</table>
"""

    #		-- Object Methods
    #		--

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.__init__()			-
    #----------------------------------------------------------------------
    def __init__(self, container, id=-1, **kwargs):
        self.assemblyAddr = (-1, -1, -1)
        #    self.auxNodeAddrs = []
        #    self.auxSubAddrs = []
        #self.axialValue = DataModel.CreateEmptyAxialValue()
        self.axialValue = AxialValue()
        self.curDataSet = None
        self.curSize = None

        #    self.nodeAddr = -1
        #    self.subAddr = ( -1, -1 )
        #    self.tallyAddr = DataModel.CreateEmptyTallyAddress()
        self.timeValue = -1.0

        #		-- Controls
        #		--
        self.headerCtrl = None
        self.webView = None

        super(DataAnalysisView, self).__init__(container, id)

    #end __init__

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView._CreateClipboardData()		-
    #----------------------------------------------------------------------
    def _CreateClipboardData(self, mode='displayed'):
        """Retrieves the from the displayed table.
@return			text or None
"""
        csv_text = ''

        return csv_text

    #end _CreateClipboardData

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView._CreateClipboardImage()	-
    #----------------------------------------------------------------------
    def _CreateClipboardImage(self):
        """Retrieves the currently-displayed bitmap.
@return			bitmap or None
"""
        bmap = wx.EmptyBitmapRGBA(400, 200)
        return bmap

    #end _CreateClipboardImage

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.CreatePrintImage()		-
    #----------------------------------------------------------------------
    def CreatePrintImage(self, file_path, bgcolor=None, hilite=False):
        """
"""
        bmap = self._CreateClipboardImage()
        im = wx.ImageFromBitmap(bmap)

        if im.HasAlpha() and bgcolor and \
            hasattr( bgcolor, '__iter__' ) and len( bgcolor ) >= 4:
            for y in xrange(im.GetHeight()):
                for x in xrange(im.GetWidth()):
                    pix_value = (im.GetRed(x, y), im.GetGreen(x, y),
                                 im.GetBlue(x, y), im.GetAlpha(x, y))
                    if pix_value == (0, 0, 0, 0) or pix_value == (255, 255,
                                                                  255, 0):
                        im.SetRGB(x, y, bgcolor[0], bgcolor[1], bgcolor[2])
                        im.SetAlpha(x, y, bgcolor[3])
        #end if bgcolor

        im.SaveFile(file_path, wx.BITMAP_TYPE_PNG)
        return file_path

    #end CreatePrintImage

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.GetAnimationIndexes()		-
    #----------------------------------------------------------------------
    def GetAnimationIndexes(self):
        """Accessor for the list of indexes over which this widget can be
animated.  Possible values are 'axial:detector', 'axial:pin', 'statepoint'.
@return			list of indexes or None
"""
        return ('axial:all', 'statepoint')

    #end GetAnimationIndexes

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.GetAxialValue()		-
    #----------------------------------------------------------------------
    def GetAxialValue(self):
        """@return		AxialValue instance
( cm value, 0-based core index, 0-based detector index
			  0-based fixed_detector index )
"""
        return self.axialValue

    #end GetAxialValue

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.GetDataSetTypes()		-
    #----------------------------------------------------------------------
    def GetDataSetTypes(self):
        return \
          (
          'channel', 'pin', 'subpin_cc',
          #'intrapin_edits', 'tally',
          )

    #end GetDataSetTypes

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.GetEventLockSet()		-
    #----------------------------------------------------------------------
    def GetEventLockSet(self):
        """By default, all locks are enabled except
"""
        locks = set([
            STATE_CHANGE_axialValue, STATE_CHANGE_coordinates,
            STATE_CHANGE_curDataSet, STATE_CHANGE_fluenceAddr,
            STATE_CHANGE_timeValue
        ])
        return locks

    #end GetEventLockSet

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.GetStateIndex()		-
    #----------------------------------------------------------------------
    def GetStateIndex(self):
        """@return		0-based state/time index
"""
        return self.stateIndex

    #end GetStateIndex

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.GetTimeValue()			-
    #----------------------------------------------------------------------
    def GetTimeValue(self):
        """@return		0-based state/time index
"""
        return self.timeValue

    #end GetTimeValue

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.GetTitle()			-
    #----------------------------------------------------------------------
    def GetTitle(self):
        return 'Data Analysis View'

    #end GetTitle

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.GetUsesScaleAndCmap()		-
    #----------------------------------------------------------------------
    def GetUsesScaleAndCmap(self):
        """
    Returns:
        boolean: False
"""
        return False

    #end GetUsesScaleAndCmap

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView._InitUI()			-
    #----------------------------------------------------------------------
    def _InitUI(self):
        """Builds this UI component.  Obviously, must be called in the UI thread.
"""
        #		-- Header
        #		--
        self.headerCtrl = wx.TextCtrl(self,
                                      wx.ID_ANY,
                                      style=wx.BORDER_NONE | wx.TE_DONTWRAP
                                      | wx.TE_READONLY)
        self.headerCtrl.SetBackgroundColour(self.GetBackgroundColour())

        #		-- View
        #		--
        if WEB_VIEW:
            self.webView = WebView.New(self)
            self.webView.SetBackgroundColour(self.GetBackgroundColour())
        else:
            self.webView = HtmlWindow(self)

#		-- Lay Out
#		--
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(
            self.headerCtrl, 0,
            wx.ALIGN_CENTRE_VERTICAL | wx.ALIGN_LEFT | wx.ALL | wx.EXPAND, 2)
        sizer.Add(self.webView, 1,
                  wx.ALL | wx.ALIGN_LEFT | wx.ALIGN_TOP | wx.EXPAND, 4)
        self.SetAutoLayout(True)
        self.SetSizer(sizer)

        #		-- Events
        #		--
        self.Bind(wx.EVT_CONTEXT_MENU, self._OnContextMenu)
        #self.Bind( wx.EVT_SIZE, self._OnSize )

    #end _InitUI

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.IsDataSetScaleCapable()	-
    #----------------------------------------------------------------------
#  def IsDataSetScaleCapable( self ):
#    """Returns False
#    Returns:
#        bool: False
#"""
#    return  False
#  #end IsDataSetScaleCapable

#----------------------------------------------------------------------
#	METHOD:		DataAnalysisView._LoadDataModel()		-
#----------------------------------------------------------------------

    def _LoadDataModel(self, reason):
        """Updates the components for the current model.
"""
        if not self.isLoading:
            update_args = self._LoadDataModelValues(reason)
            if 'rebuild' in update_args:
                wx.CallAfter(self.UpdateState, rebuild=True)

    #end _LoadDataModel

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView._LoadDataModelValues()		-
    #----------------------------------------------------------------------
    def _LoadDataModelValues(self, reason):
        """
@return			dict to be passed to UpdateState()
"""
        update_args = {}

        #if self.data is not None and self.data.HasData():
        if self.dmgr.HasData():
            update_args['rebuild'] = True

            if (reason & STATE_CHANGE_axialValue) > 0:
                update_args['axial_value'] = self.state.axialValue

            if (reason & STATE_CHANGE_coordinates) > 0:
                update_args[ 'assembly_addr' ] = self.dmgr.\
                    NormalizeAssemblyAddr( self.state.assemblyAddr )

            if (reason & STATE_CHANGE_curDataSet) > 0:
                self.curDataSet = self._FindFirstDataSet(self.state.curDataSet)

            if (reason & STATE_CHANGE_timeDataSet) > 0:
                update_args['time_dataset'] = self.state.timeDataSet

            if (reason & STATE_CHANGE_timeValue) > 0:
                update_args['time_value'] = self.state.timeValue
        #end if self.dmgr.HasData()

        return update_args

    #end _LoadDataModelValues

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.LoadProps()			-
    #----------------------------------------------------------------------
    def LoadProps(self, props_dict):
        """Called to load properties.
@param  props_dict	dict object from which to deserialize properties
"""
        # axialValue, tallyAddr handled in Widget
        for k in ('assemblyAddr', 'timeValue'):
            if k in props_dict:
                setattr(self, k, props_dict[k])

        super(DataAnalysisView, self).LoadProps(props_dict)
        wx.CallAfter(self.UpdateState, rebuild=True)

    #end LoadProps

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView._OnContextMenu()		-
    #----------------------------------------------------------------------
    def _OnContextMenu(self, ev):
        """
"""
        ev_obj = ev.GetEventObject()
        if ev_obj.HasCapture():
            ev_obj.ReleaseMouse()

        pos = ev.GetPosition()
        pos = self.ScreenToClient(pos)

        menu = self.GetPopupMenu()
        self.PopupMenu(menu, pos)

    #end _OnContextMenu

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysis.Redraw()                           -
    #----------------------------------------------------------------------
    def Redraw(self):
        """
"""
        self.UpdatePage()

    #end Redraw

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.SaveProps()			-
    #----------------------------------------------------------------------
    def SaveProps(self, props_dict, for_drag=False):
        """Called to load properties.  This implementation takes care of
'dataSetSelections' and 'timeValue', but subclasses must override for
all other properties.
@param  props_dict	dict object to which to serialize properties
"""
        super(DataAnalysisView, self).SaveProps(props_dict, for_drag=for_drag)

        # axialValue, tallyAddr handled in Widget
        for k in ('assemblyAddr', 'timeValue'):
            props_dict[k] = getattr(self, k)

    #end SaveProps

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.SetDataSet()			-
    #----------------------------------------------------------------------
    def SetDataSet(self, qds_name):
        """May be called from any thread.
"""
        if qds_name != self.curDataSet:
            wx.CallAfter(self.UpdateState, cur_dataset=qds_name)
            self.FireStateChange(cur_dataset=qds_name)

    #end SetDataSet

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.UpdatePage()			-
    #----------------------------------------------------------------------
    def UpdatePage(self):
        """Must be called from the UI thread.
"""
        html_content = ''

        #assy_ndx = self.assemblyAddr[ 0 ]
        #if assy_ndx >= 0 and self.dmgr.HasData():
        if self.dmgr.HasData():
            dset = self.dmgr.GetH5DataSet(self.curDataSet, self.timeValue)

        if dset is not None:
            core = self.dmgr.GetCore()
            ds_def = self.dmgr.GetDataSetDefByQName(self.curDataSet)
            #      assy_axis = ds_def.get( 'assy_axis', -1 )
            ds_type = ds_def.get('type', '')
            assy_axis = ds_def.get('assy_axis', -1)
            axial_axis = ds_def.get('axial_axis', -1)
            axial_index = ds_def.get('axial_index')
            axis_names = ds_def.get('axis_names', ())
            pin_axes = ds_def.get('pin_axes')
            shape_expr = ds_def.get('copy_shape_expr',
                                    ds_def.get('shape_expr'))

            #                       -- Build header
            #                       --
            table_header = os.linesep + '<tr><th>Value</th>'
            #      for n in axis_names[ ::-1 ]:
            #        if n != 'axial':
            #          table_header += '<th>' + n + '</th>'
            if axis_names:
                for ndx, name in axis_names:
                    if name != 'axial':
                        table_header += '<th>' + name.capitalize() + '</th>'
            #else:
            #table_header += '<th>&nbsp;</th>'

            table_header += '</tr>'

            #                       -- Filter dataset
            #                       --
            expr_items = [':'] * len(dset.shape)
            if axial_axis >= 0 and axial_index:
                axial_level = min(eval('self.axialValue.' + axial_index),
                                  dset.shape[axial_axis] - 1)
                expr_items[axial_axis] = str(axial_level)
                axis_names = core.CollapseAxisNames(axis_names, 'axial')

            ds_expr = '[' + ','.join(expr_items) + ']'
            data = eval('dset' + ds_expr)
            #flat_data = data[ np.logical_not( np.isnan( data ) ) ]

            #                       -- Build rows
            #                       --
            table_rows = ''

            if data is not None and data.size > 0:
                coords = zip(
                    *np.unravel_index(np.argsort(data.flatten()), data.shape))
                #for i in range( len( coords ) - 1, -1, -1 ):
                #coord = coords[ i ]
                row_count = 0
                for coord in coords[::-1]:
                    #if not self.dmgr.IsBadValue( data[ coord ] ):
                    if not np.isnan(data[coord]):
                        cur_row = '{0}<tr><td>{1}</td>'.\
                            format( os.linesep, self._CreateValueString( data[ coord ] ) )
                        if axis_names:
                            for ndx, name in axis_names:
                                if name == 'assembly':
                                    addr = self.dmgr.CreateAssemblyAddrFromIndex(
                                        coord[ndx])
                                    label = core.CreateAssyLabel(*addr[1:3])
                                elif name == 'detector':
                                    addr = self.dmgr.CreateDetectorAddrFromIndex(
                                        coord[ndx])
                                    label = core.CreateAssyLabel(*addr[1:3])
                                elif hasattr(ndx, '__iter__'):
                                    addr = [coord[i] for i in ndx]
                                    label = DataUtils.ToAddrString(*addr)
                                else:
                                    label = '{0:d}'.format(ndx + 1)

                                cur_row += '<td>{0}</td>'.format(label)
                            #end for ndx, name in axis_names

                        cur_row += '</tr>'
                        table_rows += cur_row

                        row_count += 1
                        if row_count > 100: break
                    #end if not np.isnan( data[ coord ] )
                #end for coord in coords[ ::-1 ]
            #end if data

            if WEB_VIEW:
                table_format = DataAnalysisView.DATA_TABLE
            else:
                table_format = DataAnalysisView.DATA_TABLE_HTML_VIEW
            table_content = table_format.format(header=table_header,
                                                rows=table_rows)
            html_content = DataAnalysisView.DATA_HTML.format(
                table=table_content)
        #end if dset is not None

        title_str = '{0}: Axial {1:.3f}; {2} {3:.4g}'.format(
            self.dmgr.GetDataSetDisplayName(self.curDataSet),
            self.axialValue.cm, self.state.timeDataSet, self.timeValue)
        self.headerCtrl.SetValue(title_str)
        if WEB_VIEW:
            self.webView.SetPage(html_content, '')
        else:
            self.webView.SetPage(html_content)

    #end UpdatePage

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView.UpdateState()			-
    #----------------------------------------------------------------------
    def UpdateState(self, **kwargs):
        """
Must be called from the UI thread.
"""
        if bool(self):
            kwargs = self._UpdateStateValues(**kwargs)
            if kwargs.get('rebuild', False):
                self.UpdatePage()

    #end UpdateState

    #----------------------------------------------------------------------
    #	METHOD:		DataAnalysisView._UpdateStateValues()		-
    # Must be called from the UI thread.
    #----------------------------------------------------------------------
    def _UpdateStateValues(self, **kwargs):
        """
Must be called from the UI thread.
"""
        rebuild = kwargs.get('rebuild', kwargs.get('force_redraw', False))

        if 'assembly_addr' in kwargs and \
            kwargs[ 'assembly_addr' ] != self.assemblyAddr:
            rebuild = True
            self.assemblyAddr = kwargs['assembly_addr']
        #end if

        if 'axial_value' in kwargs and \
            kwargs[ 'axial_value' ].cm != self.axialValue.cm:
            rebuild = True
            self.axialValue = \
                self.dmgr.GetAxialValue( None, cm = kwargs[ 'axial_value' ].cm )
        #end if

#		-- Special handling for cur_dataset
        if 'cur_dataset' in kwargs and kwargs['cur_dataset'] != self.curDataSet:
            ds_type = self.dmgr.GetDataSetType(kwargs['cur_dataset'])
            if ds_type and ds_type in self.GetDataSetTypes():
                rebuild = True
                self.curDataSet = kwargs['cur_dataset']
                self.container.GetDataSetMenu().Reset()
                wx.CallAfter(self.container.GetDataSetMenu().UpdateAllMenus)

                if 'dataset_added' in kwargs:
                    del kwargs['dataset_added']

                self.axialValue = self.dmgr.\
                    GetAxialValue( self.curDataSet, cm = self.axialValue.cm )
                self.stateIndex = max(
                    0,
                    self.dmgr.GetTimeValueIndex(self.timeValue,
                                                self.curDataSet))

        if 'dataset_added' in kwargs:
            wx.CallAfter(self.container.GetDataSetMenu().UpdateAllMenus)

        if 'data_model_mgr' in kwargs:
            rebuild = True

        if 'time_dataset' in kwargs:
            rebuild = True

        if 'time_value' in kwargs and kwargs['time_value'] != self.timeValue:
            rebuild = True
            self.timeValue = kwargs['time_value']

        if rebuild:
            kwargs['rebuild'] = True

        return kwargs
Esempio n. 32
0
    def SetData(self, xxx):
        self.pages = []
        # First page
        # Remove current objects and sizer
        sizer = self.ResetPage(self.page1)
        if not xxx or (not xxx.allParams and not xxx.hasName and not xxx.hasChild):
            if g.tree.selection:
                sizer.Add(wx.StaticText(self.page1, -1, 'This item has no properties.'))
            else:                       # nothing selected
                # If first time, show some help
                if g.conf.panic:
                    html = HtmlWindow(self.page1, -1, wx.DefaultPosition,
                                        wx.DefaultSize, wx.SUNKEN_BORDER)
                    html.SetPage(g.helpText)
                    sizer.Add(html, 1, wx.EXPAND)
                    g.conf.panic = False
                else:
                    sizer.Add(wx.StaticText(self.page1, -1, 'Select a tree item.'))
        else:
            g.currentXXX = xxx.treeObject()
            # Normal or SizerItem page
            isGBSizerItem = isinstance(xxx.parent, xxxGridBagSizer)
            cacheID = (xxx.panelName(), isGBSizerItem)
            try:
                page = self.pageCache[cacheID]
                page.box.SetLabel(xxx.panelName())
                page.Show()
            except KeyError:
                page = PropPage(self.page1, xxx.panelName(), xxx)
                self.pageCache[cacheID] = page
            page.SetValues(xxx)
            self.pages.append(page)
            sizer.Add(page, 1, wx.EXPAND)
            if xxx.hasChild:
                # Special label for child objects - they may have different GUI
                cacheID = (xxx.child.panelName(), xxx.__class__)
                try:
                    page = self.pageCache[cacheID]
                    page.box.SetLabel(xxx.child.panelName())
                    page.Show()
                except KeyError:
                    page = PropPage(self.page1, xxx.child.panelName(), xxx.child)
                    self.pageCache[cacheID] = page
                page.SetValues(xxx.child)
                self.pages.append(page)
                sizer.Add(page, 0, wx.EXPAND | wx.TOP, 5)
        self.page1.Layout()
        size = self.page1.GetSizer().GetMinSize()
        self.page1.SetScrollbars(1, 1, size.width, size.height, 0, 0, True)

        # Second page
        # Create if does not exist
        if xxx and xxx.treeObject().hasStyle:
            xxx = xxx.treeObject()
            # Simplest case: set data if class is the same
            sizer = self.ResetPage(self.page2)
            try:
                page = self.stylePageCache[xxx.__class__]
                page.Show()
            except KeyError:
                page = StylePage(self.page2, xxx.className + ' style', xxx)
                self.stylePageCache[xxx.__class__] = page
            page.SetValues(xxx)
            self.pages.append(page)
            sizer.Add(page, 0, wx.EXPAND)
            # Add page if not exists
            if not self.GetPageCount() == 2:
                self.AddPage(self.page2, 'Style')
            self.page2.Layout()
            if 'wxGTK' in wx.PlatformInfo:
                self.page2.Show(True)
            size = self.page2.GetSizer().GetMinSize()
            self.page2.SetScrollbars(1, 1, size.width, size.height, 0, 0, True)
        else:
            # Remove page if exists
            if self.GetPageCount() == 2:
                self.SetSelection(0)
                self.page1.Refresh()
                self.RemovePage(1)
        self.modified = False
Esempio n. 33
0
 def __init__(self, place, connect={}, **kwds):
     HtmlWindow.__init__(self, place[0], -1)
     Widget.__init__(self, place, connect, **kwds)
     self.SetStandardFonts()