Exemplo n.º 1
0
    def __init__(self, parent, D):
        """ Constructor.
		"""
        wx.Frame.__init__(self,
                          parent,
                          wx.ID_ANY,
                          _("DEVS Model Checking"),
                          size=(900, 400),
                          style=wx.DEFAULT_FRAME_STYLE)

        icon = wx.EmptyIcon()
        icon.CopyFromBitmap(
            wx.Bitmap(os.path.join(ICON_PATH_16_16, "check_master.png"),
                      wx.BITMAP_TYPE_ANY))
        self.SetIcon(icon)

        #self.CreateStatusBar(1)

        ##############################################" comment for unitest
        ### prepare dictionary
        L = []
        for k, v in D.items():

            path = ""
            line = ""
            if v is None:
                ### find mail from doc of module
                module = Components.BlockFactory.GetModule(k.python_path)
                doc = module.__doc__ or ""
                mails = GetMails(doc) if inspect.ismodule(module) else []

                ### append infos
                L.append((k.label, "", "", mails, k.python_path))
            else:
                typ, val, tb = v
                list = format_exception(typ, val, tb)
                ### reverse because we want the last error of the traceback
                list.reverse()
                ### find the line containing the 'line' word
                for s in list:
                    if 'line ' in s:
                        path, line = s.split(',')[0:2]
                        break

                ### erase whitespace and clear the Line word and the File word
                python_path = str(path.split(' ')[-1].strip())[1:-1]
                line_number = line.split(' ')[-1].strip()

                ### find mail from doc of module
                module = Components.BlockFactory.GetModule(python_path)
                doc = module.__doc__ or ""
                mails = GetMails(doc) if inspect.ismodule(module) else []

                ### append the error information
                L.append((k.label, str(val), line_number, mails, python_path))

        self.list = VirtualList(self, dict(zip(range(len(L)), L)))
        #################################################

        ### decomment for unitest
        #self.list = VirtualList(self,D)

        hsizer = wx.StdDialogButtonSizer()  #wx.BoxSizer(wx.HORIZONTAL)
        vsizer = wx.BoxSizer(wx.VERTICAL)

        close_btn = wx.Button(self, wx.ID_CLOSE)
        ok_btn = wx.Button(self, wx.ID_OK)
        update_btn = wx.Button(self, wx.ID_REFRESH)

        hsizer.Add(close_btn)
        hsizer.Add(update_btn)
        hsizer.Add(ok_btn)
        hsizer.Realize()

        vsizer.Add(self.list, 1, wx.EXPAND, 10)
        vsizer.Add(hsizer, 0, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=10)

        self.SetSizer(vsizer)
        self.Center()

        ### just for windows
        e = wx.SizeEvent(self.GetSize())
        self.ProcessEvent(e)

        self.Bind(wx.EVT_BUTTON, self.OnClose, id=close_btn.GetId())
        self.Bind(wx.EVT_BUTTON, self.OnOK, id=ok_btn.GetId())
        self.Bind(wx.EVT_BUTTON, self.OnUpdate, id=update_btn.GetId())
Exemplo n.º 2
0
 def _send_resize_event(self):
     frame = self.GetContainingWindow().GetTopLevelParent()
     frame.ProcessEvent(wx.SizeEvent(frame.Size, frame.Id))
Exemplo n.º 3
0
    def __init__(self, parent, id, title, model):
        """ Constructor
		"""

        wx.Dialog.__init__(
            self, parent, id, title, wx.DefaultPosition, (400, 280)
        )  #, style = wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)

        ### local copy
        self.model = model
        self.label = title

        self.SetTitle(_("%s - Constants Manager") % self.label)

        icon = wx.EmptyIcon()
        icon.CopyFromBitmap(
            wx.Bitmap(os.path.join(ICON_PATH_16_16, "properties.png"),
                      wx.BITMAP_TYPE_ANY))
        self.SetIcon(icon)

        self._panel = wx.Panel(self, wx.ID_ANY)

        grid_sizer_1 = wx.GridSizer(1, 2, 0, 0)

        self._grid = wx.grid.Grid(self._panel, wx.ID_ANY, size=(200, 100))
        self._grid.AutoSizeColumns(True)
        self._grid.CreateGrid(1, 2)
        self._grid.SetColLabelValue(0, _("Name"))
        self._grid.SetColSize(0, 100)
        self._grid.SetColLabelValue(1, _("Value"))
        self._grid.SetColSize(1, 100)
        ### The label windows will still exist, but they will not be visible.
        self._grid.SetRowLabelSize(0)

        # chargement des constantes
        D = self.model.constants_dico if self.model else {}

        row = 0
        self._grid.DeleteRows(0)
        for key in D:
            self._grid.AppendRows()
            self._grid.SetCellValue(row, 0, key)
            self._grid.SetCellValue(row, 1, str(D[key]))
            row += 1

        grid_sizer_1.Add(self._grid, 1, wx.EXPAND, 0)

        self._button_add = wx.Button(self._panel, wx.ID_ADD, "")
        self._button_remove = wx.Button(self._panel, wx.ID_REMOVE, "")
        self._button_help = wx.Button(self._panel, wx.ID_HELP, "")

        grid_sizer_3 = wx.GridSizer(3, 1, 0, 0)
        grid_sizer_3.Add(
            self._button_add, 0,
            wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL,
            0)
        grid_sizer_3.Add(
            self._button_remove, 0,
            wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL,
            0)
        grid_sizer_3.Add(
            (-1, 50), 0,
            wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL,
            0)

        self._button_import = wx.Button(self._panel, wx.ID_ANY, _("Import"))
        self._button_export = wx.Button(self._panel, wx.ID_ANY, _("Export"))
        self._button_import.SetDefault()

        sizer_2 = wx.BoxSizer(wx.VERTICAL)
        sizer_2.Add(
            self._button_import, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL
            | wx.ALIGN_CENTER_VERTICAL | wx.ADJUST_MINSIZE, 0)
        sizer_2.Add(
            self._button_export, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL
            | wx.ALIGN_CENTER_VERTICAL | wx.ADJUST_MINSIZE, 0)
        sizer_2.Add(
            self._button_help, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL
            | wx.ALIGN_CENTER_VERTICAL | wx.ADJUST_MINSIZE, 0)

        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_1.Add(grid_sizer_3, 1, wx.EXPAND, 0)
        sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)

        grid_sizer_1.Add(sizer_1, 1, wx.EXPAND, 0)

        self._button_cancel = wx.Button(self._panel, wx.ID_CANCEL, "")
        self._button_ok = wx.Button(self._panel, wx.ID_OK, "")

        grid_sizer_2 = wx.GridSizer(1, 2, 0, 0)
        grid_sizer_2.Add(
            self._button_cancel, 0,
            wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL | wx.ADJUST_MINSIZE,
            0)
        grid_sizer_2.Add(
            self._button_ok, 0,
            wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL | wx.ADJUST_MINSIZE,
            0)

        sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)

        self._panel.SetSizer(grid_sizer_1)

        self.__set_events()

        ### just for windows
        e = wx.SizeEvent(self.GetSize())
        self.ProcessEvent(e)

        self.Center()
Exemplo n.º 4
0
 def OnMaximize(self, event):
     self.Restore()
     self.Fit()
     wx.PostEvent(self.canvas, wx.SizeEvent(self.GetSize()))
Exemplo n.º 5
0
    def __init__(self, *args, **kwargs):
        wx.Dialog.__init__(self, *args, **kwargs)

        #local copy
        self.parent = args[0]

        ###list des item selectionnes
        self._selectedItem = {}

        ### recuperation des lib a partir du dico D du tree (library)
        lst = filter(lambda s: not self.parent.tree.IsChildRoot(s),
                     self.parent.tree.GetDomainList(
                         DOMAIN_PATH)) if self.parent else []

        exportPathsList = self.parent.exportPathsList if self.parent else []

        ### if lst is empty, perhaps DOMAIN_PATH is false
        if self.parent and lst == []:
            self.CheckDomainPath()

        ### Dico pour correspondance entre nom et path pour les exported path
        self._d = {}
        for path in exportPathsList:
            name = os.path.basename(path)
            if not self.parent.tree.IsChildRoot(name):
                lst.append(name)
                self._d[name] = os.path.abspath(path)

        ### construction du dico pour populate aves les paths local et exportes
        D = {}
        for v in lst:
            ### path is on the domain dir by default
            path = os.path.join(DOMAIN_PATH, v)
            ### else we find the path in the exportPathsList
            if not os.path.exists(path):
                for s in filter(lambda p: v in p, self.parent.exportPathsList):
                    if os.path.isdir(s):
                        path = s
                    ### update the exported path list
                    else:
                        path = None
                        i = self.parent.exportPathsList.index(s)
                        del self.parent.exportPathsList[i]

            if path: D[path] = v

        ### Panels
        panel = wx.Panel(self, wx.ID_ANY)
        leftPanel = wx.Panel(panel, wx.ID_ANY)
        rightPanel = wx.Panel(panel, wx.ID_ANY)

        ### check list of libraries
        self._cb = CheckListCtrl(rightPanel)
        ### Populate Check List dynamicaly
        wx.CallAfter(self._cb.Populate, D)

        ### Box Sizer
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox2 = wx.BoxSizer(wx.VERTICAL)
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox1 = wx.BoxSizer(wx.HORIZONTAL)

        ### Buttons
        self._dbb = filebrowse.DirBrowseButton(rightPanel,
                                               wx.ID_ANY,
                                               startDirectory=HOME_PATH,
                                               labelText=_("New"),
                                               changeCallback=self.OnChange)
        self._btn_Add = wx.Button(rightPanel, id=wx.ID_ADD)
        self._btn_Add.Enable(False)
        new = wx.Button(leftPanel, id=wx.ID_NEW, size=(100, -1))
        sel = wx.Button(leftPanel, id=wx.ID_SELECTALL, size=(100, -1))
        des = wx.Button(leftPanel,
                        wx.ID_ANY,
                        _('Deselect All'),
                        size=(100, -1))
        apply = wx.Button(leftPanel, id=wx.ID_OK, size=(100, -1))

        ### Set Sizer
        hbox1.Add(self._dbb, 1, wx.EXPAND)
        hbox1.Add(self._btn_Add, 0, wx.RIGHT | wx.CENTER, 3)

        vbox2.Add(new, 0, wx.TOP, 2)
        vbox2.Add(sel, 0, wx.TOP, 2)
        vbox2.Add(des, 0, wx.TOP, 2)
        #vbox2.Add((-1, 300))
        vbox2.Add(apply, 0, wx.TOP, 2)

        vbox.Add(self._cb, 1, wx.EXPAND | wx.TOP, 3)
        vbox.Add((-1, 10))
        vbox.Add(hbox1, 0.5, wx.EXPAND)
        vbox.Add((-1, 10))

        hbox.Add(rightPanel, 1, wx.EXPAND, 5)
        hbox.Add(leftPanel, 0, wx.EXPAND | wx.RIGHT)
        hbox.Add((3, -1))

        ### SetSizer
        leftPanel.SetSizer(vbox2)
        rightPanel.SetSizer(vbox)
        panel.SetSizer(hbox)

        ##Binding Events
        self.Bind(wx.EVT_BUTTON, self.OnNew, id=new.GetId())
        self.Bind(wx.EVT_BUTTON, self.OnSelectAll, id=sel.GetId())
        self.Bind(wx.EVT_BUTTON, self.OnDeselectAll, id=des.GetId())
        self.Bind(wx.EVT_BUTTON, self.OnAdd, self._btn_Add)
        self.Bind(wx.EVT_CHECKLISTBOX, self.EvtCheckListBox, self._cb)
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnItemRightClick)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        self.Centre()
        self.Layout()

        ### just for windows
        e = wx.SizeEvent(self.GetSize())
        self.ProcessEvent(e)
Exemplo n.º 6
0
 def testChangeSize(self):
     self.frame.ProcessEvent(wx.SizeEvent((100, 200)))
     self.assertEqual((100, 200),
                      eval(self.settings.get(self.section, 'size')))
Exemplo n.º 7
0
Arquivo: toolbar.py Projeto: bo3b/iZ3D
    def Realize(self):

        if self._art == None:
            return False

        # Calculate the size of each group and the position/size of each tool
        temp_dc = wx.MemoryDC()
        group_count = len(self._groups)

        for group in self._groups:

            prev = None
            tool_count = len(group.tools)
            tallest = 0

            for t, tool in enumerate(group.tools):

                tool.size, tool.dropdown = self._art.GetToolSize(
                    temp_dc, self, tool.bitmap.GetSize(), tool.kind, t == 0,
                    t == (tool_count - 1))
                tool.state = tool.state & ~RIBBON_TOOLBAR_TOOL_DISABLED
                if t == 0:
                    tool.state |= RIBBON_TOOLBAR_TOOL_FIRST
                if t == tool_count - 1:
                    tool.state |= RIBBON_TOOLBAR_TOOL_LAST
                if tool.size.GetHeight() > tallest:
                    tallest = tool.size.GetHeight()
                if prev:
                    tool.position = wx.Point(*prev.position)
                    tool.position.x += prev.size.x
                else:
                    tool.position = wx.Point(0, 0)

                prev = tool

            if tool_count == 0:
                group.size = wx.Size(0, 0)
            else:
                group.size = wx.Size(prev.position.x + prev.size.x, tallest)
                for tool in group.tools:
                    tool.size.SetHeight(tallest)

        # Calculate the minimum size for each possible number of rows
        sep = self._art.GetMetric(RIBBON_ART_TOOL_GROUP_SEPARATION_SIZE)
        smallest_area = 10000
        row_sizes = [wx.Size(0, 0) for i in xrange(self._nrows_max)]
        major_axis = ((self._art.GetFlags() & RIBBON_BAR_FLOW_VERTICAL)
                      and [wx.VERTICAL] or [wx.HORIZONTAL])[0]
        self.SetMinSize(wx.Size(0, 0))

        for nrows in xrange(self._nrows_min, self._nrows_max + 1):

            for r in xrange(nrows):
                row_sizes[r] = wx.Size(0, 0)

            for g in xrange(group_count):

                group = self._groups[g]
                shortest_row = 0

                for r in xrange(1, nrows):
                    if row_sizes[r].GetWidth(
                    ) < row_sizes[shortest_row].GetWidth():
                        shortest_row = r

                row_sizes[shortest_row].x += group.size.x + sep
                if group.size.y > row_sizes[shortest_row].y:
                    row_sizes[shortest_row].y = group.size.y

            size = wx.Size(0, 0)

            for r in xrange(nrows):
                if row_sizes[r].GetWidth() != 0:
                    row_sizes[r].DecBy(sep, 0)
                if row_sizes[r].GetWidth() > size.GetWidth():
                    size.SetWidth(row_sizes[r].GetWidth())

                size.IncBy(0, row_sizes[r].y)

            self._sizes[nrows - self._nrows_min] = size

            if GetSizeInOrientation(size, major_axis) < smallest_area:
                self.SetMinSize(size)
                smallest_area = GetSizeInOrientation(size, major_axis)

        # Position the groups
        dummy_event = wx.SizeEvent(self.GetSize())
        self.OnSize(dummy_event)

        return True
Exemplo n.º 8
0
 def test_SizeEvent_ctor(self):
     evt = wx.SizeEvent((1, 1))
Exemplo n.º 9
0
 def OnControlMove(self, event):
     """ When moved or sized, ignore and fill the proxy container
     """
     parent = self.GetParent()
     wx.PostEvent(parent, wx.SizeEvent( parent.GetSize() ))
Exemplo n.º 10
0
    def Realize(self):
        """
        Calculates tool layouts and positions.

        Must be called after tools are added to the tool bar, as otherwise the newly
        added tools will not be displayed.

        :note: Reimplemented from :class:`~lib.agw.ribbon.control.RibbonControl`.
        """

        if self._art == None:
            return False

        # Calculate the size of each group and the position/size of each tool
        temp_dc = wx.MemoryDC()
        group_count = len(self._groups)

        for group in self._groups:

            prev = None
            tool_count = len(group.tools)
            tallest = 0

            for t, tool in enumerate(group.tools):

                tool.size, tool.dropdown = self._art.GetToolSize(
                    temp_dc, self, tool.bitmap.GetSize(), tool.kind, t == 0,
                    t == (tool_count - 1))
                tool.state = tool.state & ~RIBBON_TOOLBAR_TOOL_DISABLED
                if t == 0:
                    tool.state |= RIBBON_TOOLBAR_TOOL_FIRST
                if t == tool_count - 1:
                    tool.state |= RIBBON_TOOLBAR_TOOL_LAST
                if tool.size.GetHeight() > tallest:
                    tallest = tool.size.GetHeight()
                if prev:
                    tool.position = wx.Point(*prev.position)
                    tool.position.x += prev.size.x
                else:
                    tool.position = wx.Point(0, 0)

                prev = tool

            if tool_count == 0:
                group.size = wx.Size(0, 0)
            else:
                group.size = wx.Size(prev.position.x + prev.size.x, tallest)
                for tool in group.tools:
                    tool.size.SetHeight(tallest)

        # Calculate the minimum size for each possible number of rows
        sep = self._art.GetMetric(RIBBON_ART_TOOL_GROUP_SEPARATION_SIZE)
        smallest_area = 10000
        row_sizes = [wx.Size(0, 0) for i in xrange(self._nrows_max)]
        major_axis = ((self._art.GetFlags() & RIBBON_BAR_FLOW_VERTICAL)
                      and [wx.VERTICAL] or [wx.HORIZONTAL])[0]
        self.SetMinSize(wx.Size(0, 0))

        minSize = wx.Size(sys.maxint, sys.maxint)

        # See if we're sizing flexibly (i.e. wrapping), and set min size differently
        sizingFlexibly = False
        panel = self.GetParent()

        if isinstance(panel, RibbonPanel) and (panel.GetFlags()
                                               & RIBBON_PANEL_FLEXIBLE):
            sizingFlexibly = True

        # Without this, there will be redundant horizontal space because SetMinSize will
        # use the smallest possible height (and therefore largest width).
        if sizingFlexibly:
            major_axis = wx.HORIZONTAL

        for nrows in xrange(self._nrows_min, self._nrows_max + 1):

            for r in xrange(nrows):
                row_sizes[r] = wx.Size(0, 0)

            for g in xrange(group_count):

                group = self._groups[g]
                shortest_row = 0

                for r in xrange(1, nrows):
                    if row_sizes[r].GetWidth(
                    ) < row_sizes[shortest_row].GetWidth():
                        shortest_row = r

                row_sizes[shortest_row].x += group.size.x + sep
                if group.size.y > row_sizes[shortest_row].y:
                    row_sizes[shortest_row].y = group.size.y

            size = wx.Size(0, 0)

            for r in xrange(nrows):
                if row_sizes[r].GetWidth() != 0:
                    row_sizes[r].DecBy(sep, 0)
                if row_sizes[r].GetWidth() > size.GetWidth():
                    size.SetWidth(row_sizes[r].GetWidth())

                size.IncBy(0, row_sizes[r].y)

            self._sizes[nrows - self._nrows_min] = size

            if GetSizeInOrientation(size, major_axis) < smallest_area:
                smallest_area = GetSizeInOrientation(size, major_axis)
                self.SetMinSize(size)

            if sizingFlexibly:
                if size.x < minSize.x:
                    minSize.x = size.x
                if size.y < minSize.y:
                    minSize.y = size.y

        if sizingFlexibly:
            # Give it the min size in either direction regardless of row,
            # so that we're able to vary the size of the panel according to
            # the space the toolbar takes up.
            self.SetMinSize(minSize)

        # Position the groups
        dummy_event = wx.SizeEvent(self.GetSize())
        self.OnSize(dummy_event)

        return True
Exemplo n.º 11
0
 def ResetParameters(self):
     #self.zoom = 1.0
     self.OnSize(wx.SizeEvent())
Exemplo n.º 12
0
    def OnSelChanged(self, event):
        print "In OnSelChanged"
        itemID = event.GetItem()
        BGcolor = self.GIVEProcTree.GetItemBackgroundColour(itemID)
        print "Item text: ", self.GIVEProcTree.GetItemText(
            itemID).lower(), " color: ", BGcolor
        itemParentID = self.GIVEProcTree.GetItemParent(itemID)
        if itemParentID == self.root:
            print "You selected a process from the process list"
            PID = self.GIVEProcTree.GetPyData(itemID)
            print "You selected PID ", PID
            self.SelectPID(
                PID, itemID
            )  # call function to fill in the detail window for the process
            self.DllList.Show(False)  # hide DLL list
            self.HandleList.Show(False)  # hide handle list
            self.SocketList.Show(False)  # hide socket list
            self.PSDetails.Show(True)
            #e = wx.SizeEvent(self.GetSize())  # cause resize event so widget appears
            #self.ProcessEvent(e)  # THIS SHOULD BE A FUNCTION
        else:
            itemText = self.GIVEProcTree.GetItemText(
                itemID).lower()  # use this to decide which to display
            if itemText == 'dlls loaded':
                print "You selected a DLL list from a process"
                PID = self.GIVEProcTree.GetPyData(itemParentID)
                self.DllList.Clear()  # clear previous results
                #cursor = GIVEFrame.DBconn.execute("SELECT PATH FROM DLLLIST WHERE PID = ?", (PID,))
                cmd = "SELECT PATH FROM DLLLIST_%s WHERE PID = ?" % self.GetParent(
                ).CaseNum
                cursor = self.DBconn.execute(cmd, (PID, ))
                for row in cursor:
                    #print row[0]  # this is the DLL name #
                    self.DllList.AppendText(str(row[0]) + '\n')
                self.PSDetails.Show(
                    False
                )  # hide the details control, show a new one with DLL info
                self.HandleList.Show(False)
                self.SocketList.Show(False)
                self.DllList.Show(True)
                #e = wx.SizeEvent(self.GetSize())  # cause resize event so widget appears
                #self.ProcessEvent(e)  # THIS SHOULD BE A FUNCTION
            elif itemText == 'process handles':
                PID = self.GIVEProcTree.GetPyData(itemParentID)
                print "You selected process handles for PID ", PID
                self.HandleList.DeleteAllItems(
                )  # clear previous results from the widget
                cmd = "SELECT HANDLE,TYPE,DETAILS FROM HANDLES_%s WHERE PID = ?" % self.GetParent(
                ).CaseNum
                cursor = self.DBconn.execute(cmd, (PID, ))
                for row in cursor:
                    #print row[0]," ",row[1]," ",row[2]
                    itemIDX = self.HandleList.InsertStringItem(
                        0, str(hex(row[0])))  # Handle ID
                    self.HandleList.SetStringItem(itemIDX, 1,
                                                  str(row[1]))  # Handle Type
                    self.HandleList.SetStringItem(itemIDX, 2, str(
                        row[2]))  # Handle Details
                self.PSDetails.Show(
                    False
                )  # hide the details control, show a new one with handle info
                self.DllList.Show(False)
                self.SocketList.Show(False)
                self.HandleList.Show(True)
                #e = wx.SizeEvent(self.GetSize())  # cause resize event so widget appears
                #self.ProcessEvent(e)  # THIS SHOULD BE A FUNCTION
            elif itemText == 'sockets':
                PID = self.GIVEProcTree.GetPyData(itemParentID)
                print "You selected sockets for PID ", PID
                self.SocketList.DeleteAllItems(
                )  # clear previous results from the widget
                cmd = "SELECT PORT,PROTO,ADDRESS,CREATETIME FROM SOCKETS_%s WHERE PID = ?" % self.GetParent(
                ).CaseNum
                cursor = self.DBconn.execute(cmd, (PID, ))
                for row in cursor:
                    #print row[0]," ",row[1]," ",row[2]
                    itemIDX = self.SocketList.InsertStringItem(0, str(
                        row[0]))  # Port #
                    self.SocketList.SetStringItem(itemIDX, 1,
                                                  str(row[1]))  # Protocol
                    self.SocketList.SetStringItem(itemIDX, 2,
                                                  str(row[2]))  # IP Address
                    self.SocketList.SetStringItem(itemIDX, 3,
                                                  str(row[3]))  # create date
                self.PSDetails.Show(
                    False
                )  # hide the details control, show a new one with handle info
                self.DllList.Show(False)
                self.HandleList.Show(False)
                self.SocketList.Show(True)

        e = wx.SizeEvent(
            self.GetSize())  # cause resize event so widget appears
        self.ProcessEvent(e)  # THIS SHOULD BE A FUNCTION
Exemplo n.º 13
0
	def __init__(self, *args, **kwargs):
		wx.Dialog.__init__(self, *args, **kwargs)

		### local copy
		self.parent = args[0]

		### selected item list
		self._selectedItem = {}

		### get libs from tree D (library)
		lst = filter(lambda s: not self.parent.tree.IsChildRoot(s), self.parent.tree.GetDomainList(DOMAIN_PATH)) if self.parent else []

		exportPathsList = self.parent.exportPathsList if self.parent else []

		### if lst is empty, perhaps DOMAIN_PATH is false
		if self.parent and lst == []:
			self.CheckDomainPath()

		### dic for name and path correspondance (for exported paths)
		self._d = {}
		for path in exportPathsList:
			name = os.path.basename(path)
			if not self.parent.tree.IsChildRoot(name):
				lst.append(name)
				self._d[name] = os.path.abspath(path)

		### dic building to populate with local and exported paths
		D = {}
		for v in lst:
			### path is on the domain dir by default
			path = os.path.join(DOMAIN_PATH, v)
			### else we find the path in the exportPathsList
			if not os.path.exists(path):
				for s in filter(lambda p : v in p, self.parent.exportPathsList):
					if os.path.isdir(s):
						path = s
					### update the exported path list
					else:
						path = None
						i = self.parent.exportPathsList.index(s)
						del self.parent.exportPathsList[i]

			if path: D[path] = v

		### Panels
		panel = wx.Panel(self, wx.ID_ANY)
		leftPanel = wx.Panel(panel, wx.ID_ANY)
		rightPanel = wx.Panel(panel, wx.ID_ANY)

		### Check list of libraries
		self._cb = CheckListCtrl(rightPanel)
		
		### Populate Check List dynamicaly
		wx.CallAfter(self._cb.Populate, D)

		### Static box sizer
		#sbox = wx.StaticBox(leftPanel, -1, '')
		#vbox2 = wx.StaticBoxSizer(sbox, wx.VERTICAL) 

		### Box Sizer
		vbox = wx.BoxSizer(wx.VERTICAL)
		vbox2 = wx.BoxSizer(wx.VERTICAL)
		hbox = wx.BoxSizer(wx.HORIZONTAL)
		hbox1 = wx.BoxSizer(wx.HORIZONTAL)

		### Buttons
		new = wx.Button(leftPanel, id = wx.ID_NEW, size=(120, -1))
		imp = wx.Button(leftPanel, wx.ID_ANY, _('Import'), size=(120, -1))
		sel = wx.Button(leftPanel, id = wx.ID_SELECTALL, size=(120, -1))
		des = wx.Button(leftPanel, wx.ID_ANY, _('Deselect All'), size=(120, -1))
		apply = wx.Button(rightPanel, id=wx.ID_OK, size=(100, -1))
		cancel = wx.Button(rightPanel, id=wx.ID_CANCEL, size=(100, -1))

		vbox2.Add(new, 0, wx.TOP, 2)
		vbox2.Add(imp, 0, wx.TOP, 2)
		#vbox2.Add((-1, 5))
		vbox2.Add(sel, 0, wx.TOP, 2)
		vbox2.Add(des, 0, wx.TOP, 2)

		hbox1.Add(cancel, 1,  wx.ALL|wx.ALIGN_CENTER, 2)
		hbox1.Add(apply, 1,  wx.ALL|wx.ALIGN_CENTER, 2)

		vbox.Add(self._cb, 1, wx.EXPAND | wx.TOP, 3)
		vbox.Add((-1, 10))
		vbox.Add(hbox1, 0.5, wx.ALL|wx.ALIGN_CENTER)
		vbox.Add((-1, 10))

		hbox.Add(rightPanel, 1, wx.EXPAND, 5, 5)
		hbox.Add(leftPanel, 0, wx.EXPAND | wx.RIGHT, 5, 5)
		hbox.Add((3, -1))

		### SetSizer
		leftPanel.SetSizer(vbox2)
		rightPanel.SetSizer(vbox)
		panel.SetSizer(hbox)

		##Binding Events
 		self.Bind(wx.EVT_BUTTON, self.OnNew, id = new.GetId())
		self.Bind(wx.EVT_BUTTON, self.OnAdd, id = imp.GetId()) 
		self.Bind(wx.EVT_BUTTON, self.OnSelectAll, id = sel.GetId())
		self.Bind(wx.EVT_BUTTON, self.OnDeselectAll, id = des.GetId())
		self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnItemRightClick)
		self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

		self.Centre()
		self.Layout()

		### just for windows
		e = wx.SizeEvent(self.GetSize())
		self.ProcessEvent(e)
Exemplo n.º 14
0
    def __init__(self, *args, **kwargs):
        super(ImportLibrary, self).__init__(*args, **kwargs)

        ### local copy
        self.parent = args[0]

        ### selected item list
        self._selectedItem = {}

        ### get libs from tree D (library)
        lst = [
            s for s in self.parent.tree.GetDomainList(DOMAIN_PATH)
            if not self.parent.tree.IsChildRoot(s)
        ] if self.parent else []

        exportPathsList = self.parent.exportPathsList if self.parent else []

        ### if lst is empty, perhaps DOMAIN_PATH is false
        if self.parent and lst == []:
            self.CheckDomainPath()

        ### dic for name and path correspondance (for exported paths)
        self._d = {}
        for path in exportPathsList:
            name = os.path.basename(path)
            if not self.parent.tree.IsChildRoot(name):
                lst.append(name)
                self._d[name] = os.path.abspath(path)

        ### dic building to populate with local and exported paths
        D = {}
        for v in lst:
            ### path is on the domain dir by default
            path = os.path.join(DOMAIN_PATH, v)
            ### else we find the path in the exportPathsList
            if not os.path.exists(path):
                for s in [p for p in self.parent.exportPathsList if v in p]:
                    if os.path.isdir(s):
                        path = s
                    ### update the exported path list
                    else:
                        path = None
                        i = self.parent.exportPathsList.index(s)
                        del self.parent.exportPathsList[i]

            if path: D[path] = v

        ### Panels
        panel = wx.Panel(self, wx.NewIdRef())
        leftPanel = wx.Panel(panel, wx.NewIdRef())
        rightPanel = wx.Panel(panel, wx.NewIdRef())

        ### Check list of libraries
        self._cb = CheckListCtrl(parent=rightPanel,
                                 style=wx.LC_REPORT | wx.SUNKEN_BORDER
                                 | wx.LC_SORT_ASCENDING)

        try:
            if wx.Platform == '__WXMSW__':
                pool = ThreadPoolExecutor(3)
                future = pool.submit(self._cb.Populate, (D))
                future.done()
            else:
                ### Populate Check List dynamicaly
                with ThreadPoolExecutor(max_workers=5) as executor:
                    executor.submit(self._cb.Populate, (D))
        except:
            self._cb.Populate(D)

        ### Static box sizer
        #sbox = wx.StaticBox(leftPanel, -1, '')
        #vbox2 = wx.StaticBoxSizer(sbox, wx.VERTICAL)

        ### Box Sizer
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox2 = wx.BoxSizer(wx.VERTICAL)
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox1 = wx.BoxSizer(wx.HORIZONTAL)

        ### Buttons
        new = wx.Button(leftPanel, id=wx.ID_NEW, size=(120, -1))
        imp = wx.Button(leftPanel, wx.NewIdRef(), _('Import'), size=(120, -1))
        sel = wx.Button(leftPanel, id=wx.ID_SELECTALL, size=(120, -1))
        des = wx.Button(leftPanel,
                        wx.NewIdRef(),
                        _('Deselect All'),
                        size=(120, -1))
        apply = wx.Button(rightPanel, id=wx.ID_OK, size=(100, -1))
        cancel = wx.Button(rightPanel, id=wx.ID_CANCEL, size=(100, -1))

        vbox2.Add(new, 0, wx.TOP | wx.LEFT, 6)
        vbox2.Add(imp, 0, wx.TOP | wx.LEFT, 6)
        #vbox2.Add((-1, 5))
        vbox2.Add(sel, 0, wx.TOP | wx.LEFT, 6)
        vbox2.Add(des, 0, wx.TOP | wx.LEFT, 6)

        hbox1.Add(cancel, 1, wx.ALL | wx.ALIGN_CENTER, 2)
        hbox1.Add(apply, 1, wx.ALL | wx.ALIGN_CENTER, 2)

        vbox.Add(self._cb, 1, wx.EXPAND | wx.TOP, 3)
        vbox.Add((-1, 10))
        vbox.Add(hbox1, 0.5, wx.ALL | wx.ALIGN_CENTER)
        vbox.Add((-1, 10))

        hbox.Add(rightPanel, 1, wx.EXPAND, 5, 5)
        hbox.Add(leftPanel, 0, wx.EXPAND | wx.RIGHT, 5, 5)
        hbox.Add((3, -1))

        ### SetSizer
        leftPanel.SetSizer(vbox2)
        rightPanel.SetSizer(vbox)
        panel.SetSizer(hbox)

        ##Binding Events
        self.Bind(wx.EVT_BUTTON, self.OnNew, id=new.GetId())
        self.Bind(wx.EVT_BUTTON, self.OnAdd, id=imp.GetId())
        self.Bind(wx.EVT_BUTTON, self.OnSelectAll, id=sel.GetId())
        self.Bind(wx.EVT_BUTTON, self.OnDeselectAll, id=des.GetId())
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnItemRightClick)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        self.Centre()
        self.Layout()

        ### just for windows
        e = wx.SizeEvent(self.GetSize())
        self.ProcessEvent(e)