Esempio n. 1
0
 def OnPrintPreview(self, event):
     """ Define the method that implements Print Preview """
     # Convert the Note Text (in plain text format) into the form needed for the
     # TranscriptPrintoutClass's Print Preview display.  (This creates graphic and pageData)
     (graphic, pageData) = TranscriptPrintoutClass.PrepareData(TransanaGlobal.printData, noteTxt = self.txt.GetValue())
     # Pass the graph can data obtained from PrepareData() to the Print Preview mechanism TWICE,
     # once for the preview and once for the printer.
     printout = TranscriptPrintoutClass.MyPrintout('', graphic, pageData)
     printout2 = TranscriptPrintoutClass.MyPrintout('', graphic, pageData)
     # use wxPython's PrintPreview object to display the Print Preview.
     self.preview = wx.PrintPreview(printout, printout2, self.printData)
     # Check to see if the Print Preview was properly created.  
     if not self.preview.Ok():
         # If not, display an error message and exit
         self.SetStatusText(_("Print Preview Problem"))
         return
     # Calculate the best size for the Print Preview window
     theWidth = max(wx.Display(TransanaGlobal.configData.primaryScreen).GetClientArea()[2] - 180, 760)  # wx.ClientDisplayRect()
     theHeight = max(wx.Display(TransanaGlobal.configData.primaryScreen).GetClientArea()[3] - 200, 560)  # wx.ClientDisplayRect()
     # Create the dialog to hold the wx.PrintPreview object
     frame2 = wx.PreviewFrame(self.preview, TransanaGlobal.menuWindow, _("Print Preview"), size=(theWidth, theHeight))
     frame2.Centre()
     # Initialize the frame so it will display correctly
     frame2.Initialize()
     # Finally, we actually show the frame!
     frame2.Show(True)
Esempio n. 2
0
    def LoadState(self, state):
        if state.get('display_index') is not None:
            try:
                display_area = wx.Display(
                    state['display_index']).GetClientArea()
            except AssertionError:
                display_area = wx.Display(0).GetClientArea()
        else:
            display_area = wx.Display(0).GetClientArea()

        if all(state.get(x) for x in ('x', 'y', 'w', 'h')):
            pos = wx.Rect(state['x'], state['y'], state['w'], state['h'])

            if not display_area.Contains(pos):
                pos = display_area

            self.SetSize(pos)

        if state.get('is_maximized', False):
            self.Maximize()

        if state.get('main_splitter_pos') is not None:
            self.main_sash_position = state['main_splitter_pos']

        if state.get('left_splitter_pos') is not None:
            self.left_sash_position = state['left_splitter_pos']
Esempio n. 3
0
    def __size(self):
        """Determine default size of Data Frame."""
        # Determine which monitor to use and get its size and position
        if TransanaGlobal.configData.primaryScreen < wx.Display.GetCount():
            primaryScreen = TransanaGlobal.configData.primaryScreen
        else:
            primaryScreen = 0
        rect = wx.Display(
            primaryScreen).GetClientArea()  # wx.ClientDisplayRect()
        if not 'wx.GTK' in wx.PlatformInfo:
            container = rect[2:4]
        else:
            screenDims = wx.Display(primaryScreen).GetClientArea()
            # screenDims2 = wx.Display(primaryScreen).GetGeometry()
            left = screenDims[0]
            top = screenDims[1]
            width = screenDims[2] - screenDims[
                0]  # min(screenDims[2], 1280 - self.left)
            height = screenDims[3]
            container = (width, height)

        width = container[0] * .282  # rect[2] * .28
        height = (container[1] - TransanaGlobal.menuHeight) * 0.931  # .66

        # Compensate in Linux.  I'm not sure why this is necessary, but it seems to be.
        #        if 'wxGTK' in wx.PlatformInfo:
        #            height -= 50

        return wx.Size(width, height)
Esempio n. 4
0
    def __size(self):
        """Determine default size of Data Frame."""
        # Determine which monitor to use and get its size and position
        if TransanaGlobal.configData.primaryScreen < wx.Display.GetCount():
            primaryScreen = TransanaGlobal.configData.primaryScreen
        else:
            primaryScreen = 0
        rect = wx.Display(
            primaryScreen).GetClientArea()  # wx.ClientDisplayRect()
        if not 'wx.GTK' in wx.PlatformInfo:
            container = rect[2:4]
        else:
            screenDims = wx.Display(primaryScreen).GetClientArea()
            left = screenDims[0]
            top = screenDims[1]
            width = screenDims[2] - screenDims[0]
            height = screenDims[3]
            container = (width, height)

        width = container[0] * .282
        height = (container[1] - TransanaGlobal.menuHeight) * 0.931

        # Windows 10 needs certain acreen adjustments to look right.
        if (platform.system() == 'Windows') and (platform.win32_ver()[0]
                                                 in ['10']):  # '8',
            width += 16
            height += 8

        # Compensate in Linux.  I'm not sure why this is necessary, but it seems to be.
#        if 'wxGTK' in wx.PlatformInfo:
#            height -= 50

        return wx.Size(width, height)
Esempio n. 5
0
    def __size(self):
        """Determine the default size for the Transcript frame."""
        # Get the size of the correct monitor
        if TransanaGlobal.configData.primaryScreen < wx.Display.GetCount():
            primaryScreen = TransanaGlobal.configData.primaryScreen
        else:
            primaryScreen = 0
        rect = wx.Display(primaryScreen).GetClientArea()
        if not ('wxGTK' in wx.PlatformInfo):
            container = rect[2:4]
        else:
            screenDims = wx.Display(primaryScreen).GetClientArea()
            # screenDims2 = wx.Display(primaryScreen).GetGeometry()
            left = screenDims[0]
            top = screenDims[1]
            width = screenDims[2] - screenDims[
                0]  # min(screenDims[2], 1280 - self.left)
            height = screenDims[3]
            container = (width, height)

        # Transcript Compontent should be 71.5% of the WIDTH
        width = container[0] * .716  # rect[2] * .715
        # Transcript Compontent should be 74% of the HEIGHT, adjusted for the menu height
        height = (container[1] - TransanaGlobal.menuHeight
                  ) * .741  # (rect[3] - TransanaGlobal.menuHeight) * .74
        # Return the SIZE values
        return wx.Size(width, height)
Esempio n. 6
0
    def __init__(self,
                 parent=None,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 id=wx.ID_ANY):
        wx.Frame.__init__(self,
                          parent,
                          id,
                          'wxLightCrafterFrame',
                          pos,
                          size,
                          style=wx.BORDER_NONE)

        numdisplays = wx.Display().GetCount()
        # The Lightcrafter should be the LAST display index. Or we'll have problems.
        displayLC = wx.Display(numdisplays - 1)

        geometry = displayLC.GetGeometry()
        # print 'Top Left' + str(geometry.GetTopLeft())
        self.SetPosition(geometry.GetTopLeft())
        self.SetSize(geometry.GetSize())

        self.LCCanvas = LightCrafterCanvas(parent=self, size=self.GetSize())

        horzsizer = wx.BoxSizer(wx.HORIZONTAL)

        horzsizer.Add(self.LCCanvas, proportion=0, flag=wx.EXPAND)
Esempio n. 7
0
 def get_display(self, window=None):
   if window is None:
     window = self.GetTopLevelParent()
   disp_idx = wx.Display.GetFromWindow(window)
   try:
     disp = wx.Display(disp_idx)
   except ValueError:
     disp = wx.Display(0)
   disp_geom = disp.GetClientArea()
   return disp_geom
Esempio n. 8
0
 def GetFromPoint(point, find_near=False):
     displaynum = wx.Display.GetFromPoint(point)
     if displaynum != wx.NOT_FOUND:
         return wx.Display(displaynum)
     if find_near:
         warnings.warn(
             'Monitor.GetFromPoint with find_near = True is not implemented (and is returning display 0)'
         )
         return wx.Display(0)
     return None
Esempio n. 9
0
        def OnPrintPreview(self, event):
            """ Print Preview Method """
            # Define a Subtitle
            subtitle = "Subtitles are optional"

            # We already have our report (our self.data structure) defined.  The data should be a list of
            # lines, and each line is a tuple of text elements.   Each text element is a tuple of Style and Text.
            # There can be multiple text elements on a line, but the report creator is responsible for making sure
            # they have different alignments and don't overlap.  A line can also be too long, in which case it is
            # automatically wrapped.
            #
            # The initial data structure needs to be prepared.  What PrepareData() does is to create a graphic
            # object that is the correct size and dimensions for the type of paper selected, and to create
            # a datastructure that breaks the data sent in into separate pages, again based on the dimensions
            # of the paper currently selected.
            (self.graphic,
             self.pageData) = PrepareData(self.printData, self.title,
                                          self.data, subtitle)

            # Send the results of the PrepareData() call to the MyPrintout object, once for the print preview
            # version and once for the printer version.
            printout = MyPrintout(self.title, self.graphic, self.pageData,
                                  subtitle)
            printout2 = MyPrintout(self.title, self.graphic, self.pageData,
                                   subtitle)

            # Create the Print Preview Object
            self.preview = wx.PrintPreview(printout, printout2, self.printData)
            # Check for errors during Print preview construction
            if not self.preview.Ok():
                self.SetStatusText("Print Preview Problem")
                return

            # Create the Frame for the Print Preview
            theWidth = max(
                wx.Display(
                    TransanaGlobal.configData.primaryScreen).GetClientArea()[2]
                - 180, 760)  # wx.ClientDisplayRect()
            theHeight = max(
                wx.Display(
                    TransanaGlobal.configData.primaryScreen).GetClientArea()[3]
                - 200, 560)  # wx.ClientDisplayRect()
            frame2 = wx.PreviewFrame(self.preview,
                                     self,
                                     _("Print Preview"),
                                     size=(theWidth, theHeight))
            frame2.Centre()
            # Initialize the Frame for the Print Preview
            frame2.Initialize()
            # Display the Print Preview Frame
            frame2.Show(True)
Esempio n. 10
0
    def LoadState(self, state):
        display_index = state.get('display_index', None)
        if display_index < wx.Display.GetCount():
            display_area = wx.Display(display_index).GetClientArea()
        else:
            display_area = wx.Display(0).GetClientArea()

        pos = wx.Rect(state.get('x', -1), state.get('y', -1),
                      state.get('w', -1), state.get('h', -1))
        if display_area.Contains(pos):
            pos = display_area
        self.frame_position = wx.Point(pos.x, pos.y)
        if state.get('is_maximized', None):
            self.export_frame.Maximize()
def getOverallDisplaysClientSize():
    """
    Estimate the rectangle of the screen real estate with all
    available displays. This assumes that all displays have same
    resolution and are positioned in a rectangular shape.
    """
    global _INITIAL_DISPLAY_CLIENT_SIZE

    # TODO: Find solution for multiple displays with taskbar always visible

    if wx.Display.GetCount() == 1:
        return wx.GetClientDisplayRect()

    # The following may be wrong if taskbar is always visible
    width = 0
    height = 0

    for i in range(wx.Display.GetCount()):
        d = wx.Display(i)

        rect = d.GetGeometry()
        width = max(width, rect.x + rect.width)
        height = max(height, rect.y + rect.height)

    # May workaround a bug
    if (width < 10 or height < 10) and (_INITIAL_DISPLAY_CLIENT_SIZE
                                        is not None):
        return _INITIAL_DISPLAY_CLIENT_SIZE

    return wx.Rect(0, 0, width, height)
Esempio n. 12
0
 def __init__(self, parent, default_text=""):
     """Initialize an NoteEditor object."""
     # Determine the screen size
     rect = wx.Display(TransanaGlobal.configData.primaryScreen
                       ).GetClientArea()  # wx.ClientDisplayRect()
     # We'll make our default window 60% of the size of the screen
     self.width = rect[2] * .60
     self.height = rect[3] * .60
     # Initialize a Dialog object to form our basic window
     wx.Dialog.__init__(
         self, parent, -1, _("Note"), wx.DefaultPosition,
         wx.Size(self.width, self.height),
         wx.CAPTION | wx.CLOSE_BOX | wx.SYSTEM_MENU | wx.RESIZE_BORDER)
     # Specify the minimium size of this window.
     self.SetMinSize((400, 220))
     # Add a Note Editor Panel to the dialog
     self.pnl = _NotePanel(self, default_text)
     # Create a Sizer for the Dialog
     dlgSizer = wx.BoxSizer(wx.HORIZONTAL)
     # Place the Panel on the Sizer, making it expandable in all directions
     dlgSizer.Add(self.pnl, 1, wx.EXPAND | wx.ALL, 2)
     # Set the Sizer to the Dialog
     self.SetSizer(dlgSizer)
     # Center the Dialog on the screen
     self.CenterOnScreen()
Esempio n. 13
0
 def ensure_on_screen(self):
     try:
         display_id = wx.Display.GetFromWindow(self)
     except NotImplementedError:
         display_id = 0
     if display_id == -1:
         display_id = 0
     geometry = wx.Display(display_id).GetGeometry()
     position = self.GetPosition()
     if position.x < geometry.x:
         position.x = geometry.x
     if position.y < geometry.y:
         position.y = geometry.y
     size = self.GetSize()
     if size.width > geometry.width:
         size.width = geometry.width
         position.x = geometry.x
     elif position.x + size.width > geometry.x + geometry.width:
         position.x = geometry.x + geometry.width - size.width
     if size.height > geometry.height:
         size.height = geometry.height
         position.y = geometry.y
     elif position.y + size.height > geometry.y + geometry.height:
         position.y = geometry.y + geometry.height - size.height
     self.SetPosition(position)
     self.SetSize(size)
Esempio n. 14
0
    def __set_properties(self):
        # begin wxGlade: MyFrame1.__set_properties
        displays = (wx.Display(i) for i in range(wx.Display.GetCount()))
        sizes = [display.GetGeometry().GetSize() for display in displays]
        displaySize = sizes[0].Get()
        xres, yres = (displaySize[0] / 1.2, displaySize[1] / 1.2)

        # begin wxGlade: MainSaint.__set_properties
        if ossystem.startswith("win"):
            buttonsize = (xres / 33 * xres / yres, yres / 33)
            textsize = (xres / 10 * xres / yres, yres / 33)
        elif ossystem.startswith("lin"):
            buttonsize = (xres / 33 * xres / yres, yres / 33)
            textsize = (xres / 10 * xres / yres, yres / 33)
        elif ossystem.startswith("darwin"):
            buttonsize = (xres / 33 * xres / yres, yres / 33)
            textsize = (xres / 10 * xres / yres, yres / 33)
        else:
            buttonsize = (xres / 33 * xres / yres, yres / 33)
            textsize = (xres / 10 * xres / yres, yres / 33)
        self.SetTitle("Choose an atom")
        self.SetSize((xres / 6 * xres / yres, yres / 4))
        self.SetMinSize((315, 250))
        self.text_ctrl1.SetMinSize((379, 30))
        self.radio_btn_1.SetMinSize((150, 30))
        self.radio_btn_1.SetValue(True)
        self.radio_btn_2.SetMinSize((107, 30))
        self.label_1.SetMinSize((xres / 6.5 * xres / yres, yres / 5))

        self.text_ctrl1.SetMinSize((250, 35))
Esempio n. 15
0
def executeMouseMoveEvent(x, y):
    global currentMouseWindow
    desktopObject = api.getDesktopObject()
    displays = [
        wx.Display(i).GetGeometry() for i in range(wx.Display.GetCount())
    ]
    x, y = getMouseRestrictedToScreens(x, y, displays)
    screenWidth, screenHeight, minPos = getTotalWidthAndHeightAndMinimumPosition(
        displays)

    if config.conf["mouse"]["audioCoordinatesOnMouseMove"]:
        playAudioCoordinates(
            x, y, screenWidth, screenHeight, minPos,
            config.conf['mouse']['audioCoordinates_detectBrightness'],
            config.conf['mouse']['audioCoordinates_blurFactor'])

    oldMouseObject = api.getMouseObject()
    mouseObject = desktopObject.objectFromPoint(x, y)
    while mouseObject and mouseObject.beTransparentToMouse:
        mouseObject = mouseObject.parent
    if not mouseObject:
        return
    if oldMouseObject == mouseObject:
        mouseObject = oldMouseObject
    else:
        api.setMouseObject(mouseObject)
    try:
        eventHandler.executeEvent("mouseMove", mouseObject, x=x, y=y)
        oldMouseObject = mouseObject
    except:
        log.error("api.notifyMouseMoved", exc_info=True)
Esempio n. 16
0
    def _set_position(self):
        pad = 20

        m_x, m_y = wx.GetMousePosition()
        s_x, s_y = self.GetSize()

        l = m_x - s_x - pad
        r = m_x + pad
        u = m_y - s_y - pad
        d = m_y + pad

        upperright = (r, u)
        upperleft = (l, u)
        bottomright = (r, d)
        bottomleft = (l, d)

        positions = (
            upperright,
            upperleft,
            bottomright,
            bottomleft,
        )

        area = wx.Display(wx.Display_GetFromPoint((m_x, m_y))).GetClientArea()

        for pos in positions:
            if area.ContainsRect(wx.Rect(pos[0], pos[1], s_x, s_y)):
                break

        self.SetPosition(pos)  #leftover from for loop
Esempio n. 17
0
def CenterOnPrimary(win):
    """ a wxWindow is passed in as the win parameter.
        This window should be centered on the primary monitor used by Transana on a multi-monitor system. """

    #    print "TransanaGlobal.CenterOnPrimary():"
    #    print win.GetRect()

    # Get the Size and Position for the PRIMARY screen
    (x1, y1, w1, h1) = wx.Display(configData.primaryScreen).GetClientArea()
    # Get the original Size and Position for the window
    (x2, y2, w2, h2) = win.GetRect()

    # I'm seeing some WEIRD values here with wxPython 2.9.??.  Let's try to correct for that.
    # If the left value is wider than the whole screen ...
    if (w2 > w1) or (w2 < 0):
        # ... set it to 50% of the screen width.
        w2 = int(w1 * 0.50)

#        print "Correcting w2 to", w2

# If the height value is taller than the whole screen ...
    if (h2 > h1) or (h2 < 0):
        # ... set it to 50% of the screen height.
        h2 = int(h1 * 0.50)

#        print "Correcting h2 to", h2
#    print

# Position the Window on the center of the Primary Screen
    win.SetPosition((x1 + ((w1 - w2) / 2), y1 + ((h1 - h2) / 2)))
Esempio n. 18
0
 def __pos(self):
     """Determine default position of Transcript Frame."""
     # Get the size of the correct monitor
     if TransanaGlobal.configData.primaryScreen < wx.Display.GetCount():
         primaryScreen = TransanaGlobal.configData.primaryScreen
     else:
         primaryScreen = 0
     rect = wx.Display(primaryScreen).GetClientArea()
     if not ('wxGTK' in wx.PlatformInfo):
         container = rect[2:4]
     else:
         # Linux rect includes both screens, so we need to use an alternate method!
         container = TransanaGlobal.menuWindow.GetSize()
     # Get the adjusted default SIZE of the Transcription UI area of the screen
     (width, height) = self.__size()
     # rect[0] compensates if Start menu is on Left
     x = rect[0] + 1
     # rect[1] compensates if Start menu is on Top
     if 'wxGTK' in wx.PlatformInfo:
         # rect2 = wx.Display(primaryScreen).GetGeometry()
         y = (rect[3] - rect[1] - 6) * .35 + 24
     else:
         y = rect[1] + container[
             1] - height  # rect[1] + rect[3] - height - 3
     # Return the POSITION values
     return (x, y)
Esempio n. 19
0
def main(data_file: str, seconds: int, downsample_factor: int, refresh: int,
         yscale: int, display_screen:int = 1):
    """Run the viewer GUI. If a raw_data.csv data_file is provided, data is
    streamed from that, otherwise it will read from an LSLDataStream by
    default. 

    Parameters:
    -----------
        data_file - optional, raw_data.csv file to stream.
        seconds - how many seconds worth of data to display.
        downsample_factor - how much the data is downsampled. A factor of 1
            displays the raw data.
        display_screen - monitor in which to display the viewer 
            (0 for primary, 1 for secondary)
    """
    data_source, device_info, proc = file_data(
        data_file) if data_file else lsl_data()

    app = wx.App(False)
    frame = EEGFrame(data_source, device_info,
                     seconds, downsample_factor, refresh, yscale)

    if wx.Display.GetCount() > 1 and display_screen == 1:
        # place frame in the second monitor if one exists.
        s2_x, s2_y, _width, _height = wx.Display(1).GetGeometry()
        offset = 30
        frame.SetPosition((s2_x + offset, s2_y + offset))

    frame.Show(True)
    app.MainLoop()
    if proc:
        proc.stop()
Esempio n. 20
0
def get_max_height(height=510):
    global _MAX_HEIGHT
    if _MAX_HEIGHT is None:
        _MAX_HEIGHT = min(height, wx.Display(0).GetGeometry().GetHeight() - 50)
        return _MAX_HEIGHT
    else:
        return _MAX_HEIGHT
Esempio n. 21
0
    def __init__(self, parent, callback):
        display = wx.Display(0)
        size = display.GetGeometry()[2:]
        st = wx.FRAME_SHAPED|wx.BORDER_SIMPLE|wx.FRAME_NO_TASKBAR|wx.STAY_ON_TOP
        wx.Frame.__init__(self, parent, -1, "", pos=(-1, size[1]//6), style=st)

        self.callback = callback

        self.Bind(wx.EVT_PAINT, self.OnPaint)

        self.bmp = DSPDemo_Icon.GetBitmap()
        self.w, self.h = self.bmp.GetWidth(), self.bmp.GetHeight()
        self.SetClientSize((self.w, self.h))

        if wx.Platform == "__WXGTK__":
            self.Bind(wx.EVT_WINDOW_CREATE, self.SetWindowShape)
        else:
            self.SetWindowShape()

        dc = wx.ClientDC(self)
        dc.DrawBitmap(self.bmp, 0, 0, True)

        wx.CallLater(2000, self.OnClose)

        self.Center(wx.HORIZONTAL)
        if sys.platform == 'win32':
            self.Center(wx.VERTICAL)

        wx.CallAfter(self.Show)
Esempio n. 22
0
    def __pos(self):
        """Determine default position of Data Frame."""
        # Determine which monitor to use and get its size and position
        if TransanaGlobal.configData.primaryScreen < wx.Display.GetCount():
            primaryScreen = TransanaGlobal.configData.primaryScreen
        else:
            primaryScreen = 0
        rect = wx.Display(primaryScreen).GetClientArea()
        if not 'wxGTK' in wx.PlatformInfo:
            container = rect[2:4]
        else:
            # Linux rect includes both screens, so we need to use an alternate method!
            container = TransanaGlobal.menuWindow.GetSize()
        (width, height) = self.__size()
        # rect[0] compensates if the Start menu is on the Left
        if 'wxGTK' in wx.PlatformInfo:
            x = rect[0] + min((rect[2] - 10), (1280 - rect[0])) - width
        else:
            x = rect[0] + container[0] - width - 2
        # rect[1] compensates if the Start menu is on the Top
        if 'wxGTK' in wx.PlatformInfo:
            y = rect[1] + rect[3] - height + 24
        else:
            y = rect[1] + container[1] - height

##        # Windows 10 needs certain acreen adjustments to look right.
##        if (platform.system() == 'Windows') and (platform.win32_ver()[0] in ['10']):  # '8',
##            y -= 8

        if DEBUG:
            print "DataWindow.__pos(): Y = %d, H = %d, Total = %d" % (
                y, height, y + height)

        return wx.Point(x, y)
Esempio n. 23
0
    def getWindowSettings(self):
        width = self.utility.read_config("window_width")
        height = self.utility.read_config("window_height")
        try:
            size = wx.Size(int(width), int(height))
        except:
            size = wx.Size(1024, 670)

        x = self.utility.read_config("window_x")
        y = self.utility.read_config("window_y")
        if (x == "" or y == "" or x == 0 or y == 0):
            # position = wx.DefaultPosition

            # On Mac, the default position will be underneath the menu bar, so lookup (top,left) of
            # the primary display
            primarydisplay = wx.Display(0)
            dsize = primarydisplay.GetClientArea()
            position = dsize.GetTopLeft()

            # Decrease size to fit on screen, if needed
            width = min(size.GetWidth(), dsize.GetWidth())
            height = min(size.GetHeight(), dsize.GetHeight())
            size = wx.Size(width, height)
        else:
            position = wx.Point(int(x), int(y))
        sashpos = self.utility.read_config("sash_position")
        try:
            sashpos = int(sashpos)
        except:
            sashpos = -185

        return size, position, sashpos
Esempio n. 24
0
    def makeOtherFrame(self, helpctrl):
        """ See long comment above, with the CallAfter line.  This is code from Robin Dunn. """
        # Get the control's Frame
        parent = helpctrl.GetFrame()
        # Create another frame with the HelpCtrl as the parent.  This provides a Top Level
        # Window that is never shown but still prevents the program from exiting when the
        # Search Dialog is closed.  Because it has the HelpCtrl as a parent, it will close
        # automatically.
        otherFrame = wx.Frame(parent)

        # Now that we have access to the Frame (because this is in a CallAfter situation),
        # we can change the size of the Help Window.  Yea!
        if parent != None:

            # Load the Config Data.  wxConfig automatically uses the Registry on Windows and the appropriate file on Mac.
            # Program Name is Transana, Vendor Name is Verception to remain compatible with Transana 1.0.
            config = wx.Config('Transana', 'Verception')
            # Load the Primary Screen setting
            primaryScreen = config.ReadInt('/2.0/PrimaryScreen', 0)

            # Get the size of the screen
            rect = wx.Display(
                primaryScreen).GetClientArea()  # wx.ClientDisplayRect()
            # Set the top to 10% of the screen height (rect[1] is for secondary monitors)
            top = int(0.1 * rect[3]) + rect[1]
            # Set the height so that the top and bottom will have equal boundaries
            height = rect[3] - (2 * top)
            # Set the window width to 80% of the screen or 1000 pixels, whichever is smaller
            width = min(int(rect[2] * 0.8), 1000)
            # Set the left margin so that the window is centered  (rect[0] is for secondary monitors)
            left = int(rect[2] / 2) - int(width / 2) + rect[0]
            # Position the window based on the calculated position
            parent.SetPosition(wx.Point(left, top))
            # Size the window based on the calculated size
            parent.SetSize(wx.Size(width, height))
Esempio n. 25
0
 def __size(self):
     """Determine the default size for the Transcript frame."""
     rect = wx.Display(TransanaGlobal.configData.primaryScreen
                       ).GetClientArea()  # wx.ClientDisplayRect()
     width = rect[2] * .715
     height = (rect[3] - TransanaGlobal.menuHeight) * .74
     return wx.Size(width, height)
Esempio n. 26
0
    def __init__(self, frame_title="", parent=None, imtypes=None):
        # Setting the GUI size and panels design
        displays = (wx.Display(i) for i in range(wx.Display.GetCount())
                    )  # Gets the number of displays
        screenSizes = [
            display.GetGeometry().GetSize() for display in displays
        ]  # Gets the size of each display
        index = 0  # For display 1.
        screenWidth = screenSizes[index][0]
        screenHeight = screenSizes[index][1]
        self.gui_size = (screenWidth * 0.8, screenHeight * 0.75)
        self.imtypes = imtypes  # imagetypes to look for in folder e.g. *.png

        wx.Frame.__init__(
            self,
            parent,
            id=wx.ID_ANY,
            title=frame_title,
            size=wx.Size(self.gui_size),
            pos=wx.DefaultPosition,
            style=wx.RESIZE_BORDER | wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL,
        )

        self.statusbar = self.CreateStatusBar()
        self.statusbar.SetStatusText("")

        # This sets the minimum size of the GUI. It can scale now!
        self.SetSizeHints(wx.Size(800, 600))
Esempio n. 27
0
    def _createAllRuntimeInfoDicts(cls):
        tempd = ioHubDialog()
        display_count = wx.Display.GetCount()

        runtime_info_list = []

        for i in range(display_count):
            d = wx.Display(i)
            mode = d.GetCurrentMode()
            x, y, w, h = d.GetGeometry()
            primary = d.IsPrimary()
            #ok=d.IsOk()
            runtime_info = dict()
            runtime_info['index'] = i
            runtime_info['pixel_width'] = w
            runtime_info['pixel_height'] = h
            runtime_info['bounds'] = (x, y, x + w, y + h)
            runtime_info['retrace_rate'] = mode.refresh
            runtime_info['bits_per_pixel'] = mode.bpp
            runtime_info['primary'] = primary
            if mode.w > 0 and mode.h > 0:
                runtime_info['pixel_resolution'] = mode.w, mode.h
            else:
                runtime_info['pixel_resolution'] = w - x, h - y

            runtime_info_list.append(runtime_info)

            # ioHub.print2err("Display {0} runtime info: {1}".format(i,runtime_info))
            del d

        tempd.Destroy()
        tempd = None

        return runtime_info_list
Esempio n. 28
0
    def ShowTip(self, x, y):
        # Ensure we're not too big (in the Y direction anyway) for the
        # desktop display area. This doesn't work on Linux because
        # ClientDisplayRect() returns the whole display size, not
        # taking the taskbar into account...

        if self.__enabled:
            theDisplay = wx.Display(wx.Display.GetFromPoint(wx.Point(x, y)))
            displayX, displayY, displayWidth, displayHeight = theDisplay.GetClientArea()
            tipWidth, tipHeight = self.__tip.GetSizeTuple()

            if tipHeight > displayHeight:
                # Too big. Take as much space as possible.
                y = 5
                tipHeight = displayHeight - 10
            elif y + tipHeight > displayY + displayHeight:
                # Adjust y so that the whole tip is visible.
                y = displayY + displayHeight - tipHeight - 5

            if tipWidth > displayWidth:
                x = 5
            elif x + tipWidth > displayX + displayWidth:
                x = displayX + displayWidth - tipWidth - 5

            self.__tip.Show(x, y, tipWidth, tipHeight)
Esempio n. 29
0
def find_closest_display(x, y):
    """ For a virtual screen position, find the closest display.
        There are a few reasons to use this function:
            * the number of displays changed
            * the size of the displays changed
            * the orientation of one or more displays changed.
    """
    closest = None
    for display_num in range(wx.Display.GetCount()):
        display = wx.Display(display_num)
        if closest is None:
            closest = display
        else:

            def _distance(x, y, display):
                dis_x, dis_y, dis_w, dis_h = display.GetGeometry()
                dis_mid_x = dis_x + dis_w // 2
                dis_mid_y = dis_y + dis_h // 2

                return (x - dis_mid_x)**2 + (y - dis_mid_y)**2

            if _distance(x, y, display) < _distance(x, y, closest):
                closest = display

    return closest
Esempio n. 30
0
    def __pos(self):
        """Determine default position of Data Frame."""
        # Determine which monitor to use and get its size and position
        if TransanaGlobal.configData.primaryScreen < wx.Display.GetCount():
            primaryScreen = TransanaGlobal.configData.primaryScreen
        else:
            primaryScreen = 0
        rect = wx.Display(
            primaryScreen).GetClientArea()  # wx.ClientDisplayRect()
        if not 'wxGTK' in wx.PlatformInfo:
            container = rect[2:4]
        else:
            # Linux rect includes both screens, so we need to use an alternate method!
            container = TransanaGlobal.menuWindow.GetSize()
        (width, height) = self.__size()
        # rect[0] compensates if the Start menu is on the Left
        if 'wxGTK' in wx.PlatformInfo:
            x = rect[0] + min(
                (rect[2] - 10),
                (1280 - rect[0])) - width  # min(rect[2], 1440) - width - 3
        else:
            x = rect[0] + container[
                0] - width - 2  # rect[0] + rect[2] - width - 3
        # rect[1] compensates if the Start menu is on the Top
        if 'wxGTK' in wx.PlatformInfo:
            y = rect[1] + rect[3] - height + 24
        else:
            y = rect[1] + container[
                1] - height  # rect[1] + rect[3] - height - 3

        if DEBUG:
            print "DataWindow.__pos(): Y = %d, H = %d, Total = %d" % (
                y, height, y + height)

        return wx.Point(x, y)