コード例 #1
0
    def __init__(self):
        wx.Frame.__init__(self,
                          parent=None,
                          title='Disable Windows 10 Tracking',
                          size=[375, 345],
                          style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER
                          ^ wx.MAXIMIZE_BOX)

        panel = wx.Panel(self)  # Frame panel

        # Test for elevation
        if ctypes.windll.shell32.IsUserAnAdmin() != 1:
            warn = wx.MessageDialog(
                parent=None,
                message=
                "Program requires elevation, please run it as an administrator",
                caption="ERROR",
                style=wx.OK | wx.ICON_WARNING)
            warn.ShowModal()
            sys.exit()

        # Get icon
        shell32file = os.path.join(os.environ['SYSTEMROOT'],
                                   'System32\\shell32.dll')
        self.SetIcon(wx.Icon(shell32file + ";315", wx.BITMAP_TYPE_ICO))

        # Info bar w/ about menu
        infomenu = wx.Menu()
        aboutitem = infomenu.Append(wx.ID_ABOUT, "About",
                                    "About the application")

        menubar = wx.MenuBar()
        menubar.Append(infomenu, "&Info")

        self.SetMenuBar(menubar)
        self.Bind(wx.EVT_MENU, self.about, aboutitem)

        # Service checkbox
        self.servicebox = wx.CheckBox(panel, label="&Services", pos=(10, 10))
        self.servicebox.SetToolTip(
            wx.ToolTip(
                "Disables or Deletes tracking services. Choose option in Service Method"
            ))
        self.Bind(wx.EVT_CHECKBOX, self.serviceradioboxcheck, self.servicebox)

        # DiagTrack checkbox
        self.diagtrackbox = wx.CheckBox(panel,
                                        label="Clear &DiagTrack log",
                                        pos=(10, 25))
        self.diagtrackbox.SetToolTip(
            wx.ToolTip(
                "Clears Diagnostic Tracking log and prevents modification to it. "
                "This cannot be undone without doing it manually."))

        # Telemetry checkbox
        self.telemetrybox = wx.CheckBox(panel,
                                        label="&Telemetry",
                                        pos=(10, 40))
        self.telemetrybox.SetToolTip(
            wx.ToolTip(
                "Sets \'AllowTelemetry\' to 0. On non-Enterprise OS editions, requires HOSTS file modification"
            ))
        self.Bind(wx.EVT_CHECKBOX, self.telemetryhostcheck, self.telemetrybox)

        # HOSTS file checkbox
        self.hostbox = wx.CheckBox(panel,
                                   label="&Block tracking domains",
                                   pos=(10, 55))
        self.hostbox.SetToolTip(
            wx.ToolTip(
                "Add known tracking domains to HOSTS file. Required to disable Telemetry"
            ))

        # Extra HOSTS checkbox
        self.extrahostbox = wx.CheckBox(
            panel, label="Block &even more tracking domains", pos=(10, 70))
        self.extrahostbox.SetToolTip(
            wx.ToolTip(
                "For the paranoid. Adds extra domains to the HOSTS file. WARNING: Some "
                "things like Dr. Watson and Error Reporting may be turned off by this"
            ))

        # IP block checkbox
        self.ipbox = wx.CheckBox(panel,
                                 label="Block tracking &IP addresses",
                                 pos=(10, 85))
        self.ipbox.SetToolTip(
            wx.ToolTip(
                "Blocks known tracking IP addresses with Windows Firewall."))

        # Windows Defender/Wifisense
        self.defendwifibox = wx.CheckBox(
            panel,
            label="Stop Defender&/Wifisense Data Collection",
            pos=(10, 100))
        self.defendwifibox.SetToolTip(
            wx.ToolTip(
                "Modifies registry to stop Windows Defender and WifiSense from "
                "Data Collecting."))

        # OneDrive uninstall checkbox
        self.onedrivedbox = wx.CheckBox(panel,
                                        label="Uninstall &OneDrive",
                                        pos=(10, 115))
        self.onedrivedbox.SetToolTip(
            wx.ToolTip(
                "Uninstalls OneDrive from your computer and removes it from Explorer."
            ))

        # App static box
        self.appbox = wx.StaticBox(panel,
                                   label="Built-in Apps",
                                   pos=(10, 130),
                                   size=(351, 160))

        self.builderbox = wx.CheckBox(self.appbox,
                                      label="&3D Builder",
                                      pos=(10, 15))
        self.calmailbox = wx.CheckBox(self.appbox,
                                      label="C&alender && Mail",
                                      pos=(10, 30))
        self.camerabox = wx.CheckBox(self.appbox,
                                     label="&Camera",
                                     pos=(10, 45))
        self.officebox = wx.CheckBox(self.appbox,
                                     label="Get &Office App",
                                     pos=(10, 60))
        self.skypebox = wx.CheckBox(self.appbox,
                                    label="Get S&kype App",
                                    pos=(10, 75))
        self.startbox = wx.CheckBox(self.appbox,
                                    label="Get S&tarted App",
                                    pos=(10, 90))
        self.groovebox = wx.CheckBox(self.appbox,
                                     label="&Groove Music",
                                     pos=(10, 105))
        self.mapbox = wx.CheckBox(self.appbox, label="&Maps", pos=(120, 15))
        self.mscbox = wx.CheckBox(self.appbox,
                                  label="Microso&ft Solitaire Collection",
                                  pos=(120, 105))
        self.moneybox = wx.CheckBox(self.appbox, label="Mone&y", pos=(120, 30))
        self.movietvbox = wx.CheckBox(
            self.appbox, label="Movies && T&V",
            pos=(120, 45))  # For some reason & is an underscore
        self.newsbox = wx.CheckBox(self.appbox, label="&News", pos=(120, 60))
        self.onenotebox = wx.CheckBox(self.appbox,
                                      label="OneNote Ap&p",
                                      pos=(120, 75))
        self.peoplebox = wx.CheckBox(self.appbox,
                                     label="P&eople",
                                     pos=(120, 90))
        self.phonebox = wx.CheckBox(self.appbox,
                                    label="Phone Compan&ion",
                                    pos=(225, 15))
        self.photosbox = wx.CheckBox(self.appbox,
                                     label="P&hotos",
                                     pos=(225, 30))
        self.sportsbox = wx.CheckBox(self.appbox,
                                     label="&Sports",
                                     pos=(225, 45))
        self.voicebox = wx.CheckBox(self.appbox,
                                    label="Voice &Recorder",
                                    pos=(225, 60))
        self.weatherbox = wx.CheckBox(self.appbox,
                                      label="&Weather",
                                      pos=(225, 75))
        self.xbonebox = wx.CheckBox(self.appbox, label="&Xbox", pos=(225, 90))

        self.selectapps = wx.CheckBox(self.appbox,
                                      label="Select all apps",
                                      pos=(246, 0),
                                      style=wx.ALIGN_RIGHT)
        self.Bind(wx.EVT_CHECKBOX, self.selectallapps, self.selectapps)

        self.removeappbut = wx.Button(self.appbox,
                                      wx.ID_ANY,
                                      label="Uninstall selected apps",
                                      pos=(10, 125))
        self.removeappbut.SetToolTip(
            wx.ToolTip(
                "Uninstalls all of the selected apps. May take a lot of time.")
        )
        self.Bind(wx.EVT_BUTTON, self.uninstapps, self.removeappbut)

        self.reinstappbut = wx.Button(self.appbox,
                                      wx.ID_ANY,
                                      label="Reinstall original apps",
                                      pos=(205, 125))
        self.reinstappbut.SetToolTip(
            wx.ToolTip(
                "Reinstalls ALL of the default apps. Takes a lot of time."))
        self.Bind(wx.EVT_BUTTON, self.reinstapps, self.reinstappbut)

        # Service radio box
        self.serviceradbox = wx.RadioBox(panel,
                                         label="Service Method",
                                         pos=(135, 5),
                                         choices=["Disable", "Delete"])
        self.serviceradbox.Disable()

        # OK button
        self.okbutton = wx.Button(panel,
                                  wx.ID_OK,
                                  label="Get privacy!",
                                  pos=(275, 25))
        self.okbutton.SetToolTip(wx.ToolTip("Give me my privacy, damn it!"))
        self.Bind(wx.EVT_BUTTON, self.goprivate, self.okbutton)

        # Revert button
        self.revertbutton = wx.Button(panel,
                                      wx.ID_ANY,
                                      label="Revert",
                                      pos=(275, 50))
        self.revertbutton.SetToolTip(wx.ToolTip("I wanna go back! :("))
        self.Bind(wx.EVT_BUTTON, self.revert, self.revertbutton)

        # Fix Button
        self.fixbutton = wx.Button(panel,
                                   wx.ID_ANY,
                                   label="Fix Skype/Mail",
                                   pos=(266, 75))
        self.fixbutton.SetToolTip(
            wx.ToolTip(
                "Press this if you're having issues with Skype or the Mail app"
            ))
        self.Bind(wx.EVT_BUTTON, self.skypemailfix, self.fixbutton)

        self.console = ConsoleFrame(
        )  # Call ConsoleFrame to start redirecting stdout to a TextCtrl

        # Center and show the window
        self.Centre()
        self.Show()
コード例 #2
0
ファイル: pyFileRen.py プロジェクト: jinook0707/pyFileRenamer
    def __init__(self):
        if DEBUG: print("FileRenamerFrame.__init__()")

        ### init frame
        w_pos = [0, 25]
        wg = wx.Display(0).GetGeometry()
        w_sz = (wg[2], int(wg[3]*0.9))
        wx.Frame.__init__(
              self, 
              None, 
              -1, 
              "File Renamer v.%s"%(__version__), 
              pos = tuple(w_pos), 
              size = tuple(w_sz),
              style=wx.DEFAULT_FRAME_STYLE^(wx.RESIZE_BORDER|wx.MAXIMIZE_BOX),
                         ) 
        self.SetBackgroundColour('#333333')

        ### set app icon
        self.tbIcon = wx.adv.TaskBarIcon(iconType=wx.adv.TBI_DOCK)
        icon = wx.Icon("icon.ico")
        self.tbIcon.SetIcon(icon)

        ##### beginning of setting up attributes ----- 
        self.w_pos = w_pos
        self.w_sz = w_sz
        self.fonts = getWXFonts(initFontSz=8, numFonts=3)
        pi = self.setPanelInfo()
        self.pi = pi # pnael information
        self.gbs = {} # for GridBagSizer
        self.panel = {} # panels
        self.selectedFolders = [] # list of selected folders
        self.folder2moveRenFile = "" # folder to move renamed files
        self.fileList = [] # file list to be renamed
        self.nFileList = [] # file list with new file names
        self.newFFO = [
                        'oFileN', 
                        'folderN', 
                        'incNum', 
                        'incNumInFolder', 
                        'ts',
                      ] # new file format options 
        self.newFFOD = dict(
                            oFileN = 'Original file-name',
                            folderN = 'Folder name', 
                            incNum = 'Increasing Number (overall)',
                            incNumInFolder = 'Increasing Number (in each folder)',
                            ts = 'Timestamp',
                            ) # new file format options - description
        self.logFile = "log_pyFileRen.txt"
        ##### end of setting up attributes -----  
        
        logHeader = "Timestamp, Origianl file, Renamed file\n"
        logHeader += "----------------------------------------\n"
        if not path.isfile(self.logFile): # log file doesn't exist
            writeFile(self.logFile, logHeader) # write header

        ### create panels
        for pk in pi.keys():
            self.panel[pk] = SPanel.ScrolledPanel(
                                                  self, 
                                                  name="%s_panel"%(pk), 
                                                  pos=pi[pk]["pos"], 
                                                  size=pi[pk]["sz"], 
                                                  style=pi[pk]["style"],
                                                 )
            self.panel[pk].SetBackgroundColour(pi[pk]["bgCol"]) 

        ##### beginning of setting up top UI panel interface -----
        bw = 5 # border width for GridBagSizer
        vlSz = (-1, 20) # size of vertical line seprator
        self.gbs["tUI"] = wx.GridBagSizer(0,0)
        row = 0
        col = 0
        btn = wx.Button(
                            self.panel["tUI"],
                            -1,
                            label="Select folders",
                            name="selFolders_btn",
                       )
        btn.Bind(wx.EVT_LEFT_DOWN, self.onButtonPressDown)
        self.gbs["tUI"].Add(
                            btn, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           )
        col += 1
        chk = wx.CheckBox(
                            self.panel["tUI"],
                            -1,
                            label="Include sub-folders",
                            name="subFolders_chk",
                         )
        chk.SetValue(False)
        self.gbs["tUI"].Add(
                            chk, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           )
        col += 1
        self.gbs["tUI"].Add(
                            wx.StaticLine(
                                            self.panel["tUI"],
                                            -1,
                                            size=vlSz,
                                            style=wx.LI_VERTICAL,
                                         ),
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           ) # vertical line separator
        col += 1
        chk = wx.CheckBox(
                            self.panel["tUI"],
                            -1,
                            label="Move renamed files to a folder",
                            name="moveRenFiles_chk",
                         )
        chk.SetValue(False)
        chk.Bind(wx.EVT_CHECKBOX, self.onCheckBox)
        self.gbs["tUI"].Add(
                            chk, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           )
        col += 1
        btn = wx.Button(
                            self.panel["tUI"],
                            -1,
                            label="Select folder to move renamed Files",
                            name="selFolder2move_btn",
                       )
        btn.Disable()
        btn.Bind(wx.EVT_LEFT_DOWN, self.onButtonPressDown)
        self.gbs["tUI"].Add(
                            btn, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           )
        col += 1
        txt = wx.TextCtrl(
                            self.panel["tUI"], 
                            -1, 
                            value="",
                            name="selFolder2move_txt",
                            size=(200,-1),
                            style=wx.TE_READONLY,
                         )
        txt.Disable()
        txt.SetBackgroundColour('#999999')
        self.gbs["tUI"].Add(
                            txt, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           )
        col += 1
        self.gbs["tUI"].Add(
                            wx.StaticLine(
                                            self.panel["tUI"],
                                            -1,
                                            size=vlSz,
                                            style=wx.LI_VERTICAL,
                                         ),
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           ) # vertical line separator
        col += 1
        btn = wx.Button(
                            self.panel["tUI"],
                            -1,
                            label="Run renaming",
                            name="run_btn",
                       )
        btn.Bind(wx.EVT_LEFT_DOWN, self.onButtonPressDown)
        self.gbs["tUI"].Add(
                            btn, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           )
        self.panel["tUI"].SetSizer(self.gbs["tUI"])
        self.gbs["tUI"].Layout()
        self.panel["tUI"].SetupScrolling()
        ##### end of setting up top UI panel interface -----

        ##### beginning of setting up renaming parameter panel interface -----
        mw = bw*6 # margin in width
        mpSz = pi["mp"]["sz"]
        hlSz = (mpSz[0]-mw, -1) # size of horizontal line separator
        self.gbs["mp"] = wx.GridBagSizer(0,0)
        row = 0
        col = 0
        sTxt = setupStaticText(
                            self.panel["mp"], 
                            "Selected folders for renaming", 
                            font=self.fonts[2],
                              )
        self.gbs["mp"].Add(
                            sTxt, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           )
        row += 1
        txt = wx.TextCtrl(
                            self.panel["mp"], 
                            -1, 
                            value="[EMPTY]; Please select folders",
                            name="selDir_txt",
                            size=(int(mpSz[0]*0.95), int(mpSz[1]*0.2)),
                            style=wx.TE_MULTILINE|wx.TE_READONLY,
                         )
        txt.SetBackgroundColour('#999999')
        self.gbs["mp"].Add(
                            txt, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           ) 
        row += 1
        self.gbs["mp"].Add(
                            wx.StaticLine(
                                            self.panel["mp"],
                                            -1,
                                            size=hlSz,
                                            style=wx.LI_HORIZONTAL,
                                         ),
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                          ) # horizontal line separator
        row += 1
        lbl = "Target files (you can use wildcard characters)"
        sTxt = setupStaticText(
                            self.panel["mp"], 
                            lbl, 
                            font=self.fonts[2],
                              )
        self.gbs["mp"].Add(
                            sTxt, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           )
        row += 1
        txt = wx.TextCtrl(
                            self.panel["mp"], 
                            -1, 
                            value="*.*",
                            name="targetFN_txt",
                            size=(int(mpSz[0]*0.95), -1),
                            style=wx.TE_PROCESS_ENTER,
                         )
        txt.Bind(wx.EVT_TEXT_ENTER, self.onEnteredInTC)
        self.gbs["mp"].Add(
                            txt, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                          )
        row += 1
        col = 0
        self.gbs["mp"].Add(
                            wx.StaticLine(
                                            self.panel["mp"],
                                            -1,
                                            size=hlSz,
                                            style=wx.LI_HORIZONTAL,
                                         ),
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                          ) # horizontal line separator
        row += 1
        sTxt = setupStaticText(
                            self.panel["mp"], 
                            "List of files to be renamed", 
                            font=self.fonts[2],
                              )
        self.gbs["mp"].Add(
                            sTxt, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           )
        row += 1
        txt = wx.richtext.RichTextCtrl(
                            self.panel["mp"], 
                            -1, 
                            name="selFile_txt",
                            size=(int(mpSz[0]*0.95), int(mpSz[1]*0.4)),
                            style=wx.TE_MULTILINE|wx.TE_READONLY,
                         ) # selected files to be renamed
        txt.SetBackgroundColour('#999999')
        self.gbs["mp"].Add(
                            txt, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           )
        row += 1
        self.gbs["mp"].Add(
                            wx.StaticLine(
                                            self.panel["mp"],
                                            -1,
                                            size=hlSz,
                                            style=wx.LI_HORIZONTAL,
                                         ),
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                          ) # horizontal line separator
        row += 1
        lbl = "New file-name format (Don't put extension here."
        lbl += " It will be same as original file extension.)"
        sTxt = setupStaticText(
                            self.panel["mp"], 
                            lbl, 
                            font=self.fonts[2],
                            wrapWidth=int(mpSz[0]*0.95),
                              )
        self.gbs["mp"].Add(
                            sTxt, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           )
        row += 1
        txt = wx.TextCtrl(
                            self.panel["mp"], 
                            -1, 
                            value="[oFileN]",
                            name="newFN_txt",
                            size=(int(mpSz[0]*0.95), -1),
                            style=wx.TE_PROCESS_ENTER,
                         )
        txt.Bind(wx.EVT_TEXT_ENTER, self.onEnteredInTC)
        self.gbs["mp"].Add(
                            txt, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           )
        row += 1
        _choices = ['']
        for i in range(len(self.newFFO)):
            k = self.newFFO[i]
            _choices.append("[%s], %s"%(k, self.newFFOD[k]))
        cho = wx.Choice(
                            self.panel["mp"], 
                            -1,
                            name="newFNOption_cho",
                            choices=_choices,
                            size=(int(mpSz[0]*0.333), -1),
                       )
        cho.Bind(wx.EVT_CHOICE, self.onChoice)
        self.gbs["mp"].Add(
                            cho, 
                            pos=(row,col), 
                            flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, 
                            border=bw,
                           )
        self.panel["mp"].SetSizer(self.gbs["mp"])
        self.gbs["mp"].Layout()
        self.panel["mp"].SetupScrolling()
        ##### end of setting up renaming parameter panel interface -----

        ### set up menu
        menuBar = wx.MenuBar()
        fileRenMenu = wx.Menu()
        selectFolders = fileRenMenu.Append(
                            wx.Window.NewControlId(), 
                            item="Select folders\tCTRL+O",
                                        )
        self.Bind(wx.EVT_MENU,
                  lambda event: self.onButtonPressDown(event, 'selectFolders'),
                  selectFolders)
        quit = fileRenMenu.Append(
                            wx.Window.NewControlId(), 
                            item="Quit\tCTRL+Q",
                                 )
        menuBar.Append(fileRenMenu, "&FileRenamer")
        self.SetMenuBar(menuBar)
        
        ### set up hot keys
        idSelFolders = wx.Window.NewControlId()
        idQuit = wx.Window.NewControlId()
        self.Bind(wx.EVT_MENU,
                  lambda event: self.onButtonPressDown(event, 'selectFolders'),
                  id=idSelFolders)
        self.Bind(wx.EVT_MENU, self.onClose, id=idQuit)
        accel_tbl = wx.AcceleratorTable([ 
                                    (wx.ACCEL_CMD,  ord('O'), idSelFolders), 
                                    (wx.ACCEL_CMD,  ord('Q'), idQuit), 
                                        ]) 
        self.SetAcceleratorTable(accel_tbl)

        updateFrameSize(self, w_sz)

        self.Bind(wx.EVT_CLOSE, self.onClose)
コード例 #3
0
    def __init__(self, parent, lbl, hid):
        wx.Frame.__init__(self, parent, title=lbl, size=wx.Size(850, 650))

        t = type(hid)
        if t == h5py.h5d.DatasetID:
            data = h5py.Dataset(hid)

        self.data = data
        self.idxXY = (data.ndim - 2, data.ndim - 1)
        self.slice_idx = [
            0,
        ] * data.ndim

        imgDir = ut.Path.GetImage()
        icon = wx.Icon(os.path.join(imgDir, 'h5pyViewer.ico'),
                       wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)

        canvas = MPLCanvasImg(self, self.SetStatusCB)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND)
        self.SetSizer(sizer)

        toolbar = ut.AddToolbar(canvas, sizer)

        xy_sel_sizer = wx.BoxSizer(wx.HORIZONTAL)
        xy_sel_sizer.Add(wx.StaticText(self, label="X Axis:"), 0,
                         wx.ALIGN_CENTER_VERTICAL)
        x_axis_combo = wx.ComboBox(self,
                                   -1,
                                   choices=tuple(
                                       str(x) for x in range(0, data.ndim)),
                                   style=wx.CB_READONLY,
                                   size=wx.Size(100, -1))
        x_axis_combo.SetValue(str(self.idxXY[0]))

        xy_sel_sizer.Add(x_axis_combo,
                         0,
                         wx.ALIGN_CENTER_VERTICAL | wx.LEFT,
                         border=5)
        xy_sel_sizer.Add(wx.StaticText(self, label="Y Axis:"),
                         0,
                         wx.ALIGN_CENTER_VERTICAL | wx.LEFT,
                         border=20)
        y_axis_combo = wx.ComboBox(self,
                                   -1,
                                   choices=tuple(
                                       str(x) for x in range(0, data.ndim)),
                                   style=wx.CB_READONLY,
                                   size=wx.Size(100, -1))
        y_axis_combo.SetValue(str(self.idxXY[1]))
        xy_sel_sizer.Add(y_axis_combo,
                         0,
                         wx.ALIGN_CENTER_VERTICAL | wx.LEFT,
                         border=5)

        xy_sel_sizer.Add(wx.StaticText(self,
                                       label="Shape: %s" % (data.shape, )),
                         0,
                         wx.ALIGN_CENTER_VERTICAL | wx.LEFT,
                         border=20)

        self.Bind(wx.EVT_COMBOBOX, self.OnSetAxes, x_axis_combo)
        self.Bind(wx.EVT_COMBOBOX, self.OnSetAxes, y_axis_combo)
        self.x_axis_combo = x_axis_combo
        self.y_axis_combo = y_axis_combo
        sizer.Add(xy_sel_sizer,
                  0,
                  wx.ALIGN_LEFT | wx.EXPAND | wx.ALL,
                  border=5)

        self.wxAxCtrlLst = []
        for idx, l in enumerate(data.shape):
            if idx in self.idxXY:
                continue
            wxAxCtrl = ut.SliderGroup(self, label='', range=(0, 1))
            wxAxCtrl.idx = idx
            self.wxAxCtrlLst.append(wxAxCtrl)
            sizer.Add(wxAxCtrl.sizer,
                      0,
                      wx.EXPAND | wx.ALIGN_CENTER | wx.ALL,
                      border=5)
            wxAxCtrl.SetCallback(HdfImageFrame.OnSetView, wxAxCtrl)
        self.updateSliceSliders()

        canvas.InitChild(self.getSliceArray())

        #self.Fit()
        self.Centre()

        self.BuildMenu(data.dtype)
        self.canvas = canvas
        self.sizer = sizer
        self.toolbar = toolbar
コード例 #4
0
ファイル: IRIDA.py プロジェクト: YautongNg/gengis
	def __init__(self, IRIDA):
		IRIDALoginLayout.__init__(self,None)
		self.SetIcon(wx.Icon(GenGIS.mainWindow.GetExeDir() + "images/CrazyEye.ico",wx.BITMAP_TYPE_ICO))
		self.interface = IRIDA
		self.success = False
コード例 #5
0
    def __init__(self, title):
        """Initialize the main window.

        @param title  Title for the main window.
        """
        from sb.widget.area import Area

        # Commands for the popup menu.
        self.menuCommandMap = {}

        # FIXME: Layout is botched. Way too wide.
        if host.isMac():
            initialSize = (769, 559)
        elif host.isUnix():
            initialSize = (900, 610)
        else:
            initialSize = (733, 527)

        # The configuration may define a window size.
        if st.isDefined('main-width'):
            initialSize = (st.getSystemInteger('main-width'), initialSize[1])
        if st.isDefined('main-height'):
            initialSize = (initialSize[0], st.getSystemInteger('main-height'))

        # The configuration can also specify the window position.
        if st.isDefined('main-x') and st.isDefined('main-y'):
            initialPos = (st.getSystemInteger('main-x'),
                          st.getSystemInteger('main-y'))
        else:
            initialPos = None

        wx.Frame.__init__(self, None, -1, title, size=initialSize)
        #self.SetExtraStyle(wx.FRAME_EX_METAL)
        #self.Create(None, -1, title, size=initialSize)

        if initialPos is not None:
            self.MoveXY(*initialPos)
        else:
            self.Center()

        # Set the icon for the frame.
        icon = wx.Icon('graphics/snowberry.ico', wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)

        #self.Iconize(True)
        #self.Hide()

        SPLITTER_ID = 9501
        PROF_SPLITTER_ID = 9502
        self.splitter = None
        self.profSplitter = None

        # The parentWin is where the profSplitter and the help panel
        # are inside.
        parentWin = self

        if USE_HELP_AREA:
            # The help area is in a splitter.
            self.splitter = wx.SplitterWindow(self,
                                              SPLITTER_ID,
                                              style=wx.SP_3DSASH)
            self.splitter.SetMinimumPaneSize(10)
            parentWin = self.splitter

        if not USE_MINIMAL_PROFILE:
            self.profSplitter = wx.SplitterWindow(parentWin,
                                                  PROF_SPLITTER_ID,
                                                  style=wx.SP_3DSASH)  # |
            #wx.SP_NO_XP_THEME)
            self.profSplitter.SetMinimumPaneSize(100)

            # Profile panel.
            profilePanel = wx.Panel(self.profSplitter,
                                    -1,
                                    style=wx.NO_BORDER
                                    | wx.CLIP_CHILDREN)
            area = Area(PROFILES, profilePanel, ALIGN_VERTICAL, 10)
            _newArea(area)

            # Create panels inside the profile splitter.
            self.mainPanel = MainPanel(self.profSplitter)
        else:
            profilePanel = None

            self.mainPanel = MainPanel(parentWin)

            getArea(TABS).setWeight(0)
            profArea = getArea(TABS).createArea(alignment=ALIGN_HORIZONTAL,
                                                border=12)
            profArea.setId(PROFILES)
            _newArea(profArea)
            getArea(TABS).setWeight(1)
            getArea(TABS).setBorderDirs(BORDER_NOT_TOP)

        # Create a TabArea into the TABS area.
        self.mainPanel.tabs = getArea(TABS).createTabArea(
            'tab', style=sb.widget.tab.TabArea.STYLE_BASIC)

        if st.isDefined('main-split-position'):
            self.splitPos = INITIAL_SASH_POS
        else:
            self.splitPos = None
        self.profSplitPos = INITIAL_PROFILE_SASH_POS

        # Create the help area.
        if self.splitter:
            self.helpPanel = wx.Panel(self.splitter,
                                      -1,
                                      style=wx.NO_BORDER
                                      | wx.CLIP_CHILDREN)
            self.helpPanel.SetBackgroundColour(wx.WHITE)
            _newArea(Area(HELP, self.helpPanel, ALIGN_VERTICAL, border=4))
            # Init the splitter.
            leftSide = self.profSplitter
            if not leftSide:
                leftSide = self.mainPanel
            self.splitter.SplitVertically(leftSide, self.helpPanel,
                                          -INITIAL_SASH_POS)
        else:
            self.helpPanel = None

        if self.profSplitter:
            self.profSplitter.SplitVertically(profilePanel, self.mainPanel,
                                              self.profSplitPos)

        # Listen for changes in the sash position.
        wx.EVT_SPLITTER_SASH_POS_CHANGED(self, SPLITTER_ID, self.onSplitChange)
        wx.EVT_SPLITTER_SASH_POS_CHANGED(self, PROF_SPLITTER_ID,
                                         self.onProfSplitChange)

        # The main panel should be globally accessible.
        global mainPanel
        mainPanel = self.mainPanel

        # Intercept the window close event.
        wx.EVT_CLOSE(self, self.onWindowClose)

        # Maintain the splitter position.
        wx.EVT_SIZE(self, self.onWindowSize)

        # Listen to some commands.
        events.addCommandListener(self.handleCommand, ['quit'])

        # Create a menu bar.
        self.menuBar = wx.MenuBar()
    def __init__(self, parent):

        print "===> VirusGUIalert.py initiated"

        #         stime_= strftime("%H-%M-%S-%MS", time.localtime())
        self.dialogID = "500003"
        self.dialogTag = "VIRUS_ALERT"
        self.name = "Virus alert"
        wx.Dialog.__init__(self,
                           parent=parent,
                           id=-1,
                           name='Virus Defender System')
        wx.Dialog.SetSize(self, (width, 200 + len(virusName) * 25))

        ico = wx.Icon(
            globalTracker.propertyVar.phase3images + '/firewallIcon.png',
            wx.BITMAP_TYPE_ANY)
        self.SetIcon(ico)
        self.SetTitle("Virus Alert")
        self.CenterOnScreen()
        #         globalTracker.math.changeStatusFromUntoInitialized(mathsQNumber, loadNumber)

        wx.Dialog.SetBackgroundColour(self, "#FFFFFF")
        panel = wx.Panel(self)
        self.Bind(wx.EVT_CLOSE, self.onClose)
        threatDetectedInfo = wx.StaticText(panel,
                                           label="Threat Detected!",
                                           style=wx.EXPAND | wx.CENTER
                                           | wx.NO_BORDER)
        threatDetectedInfo.SetForegroundColour((255, 0, 0))  # set text color
        threatDetectedInfo.SetBackgroundColour("White")

        threatDetectedInfo.SetFont(
            wx.Font(24, wx.MODERN, wx.NORMAL, wx.BOLD, False,
                    u'Times New Roman'))

        self.detectedThreatListCtrl = ULC.UltimateListCtrl(
            panel,
            wx.ID_ANY,
            agwStyle=wx.LC_REPORT | wx.BORDER_SUNKEN | wx.LC_SINGLE_SEL
            | ULC.ULC_HAS_VARIABLE_ROW_HEIGHT)
        self.detectedThreatListCtrl.InsertColumn(0,
                                                 "Detected Item",
                                                 width=0.41 * width)
        self.detectedThreatListCtrl.InsertColumn(1,
                                                 "Alert Level",
                                                 width=0.166 * width)
        self.detectedThreatListCtrl.InsertColumn(2,
                                                 "Action",
                                                 width=0.166 * width)
        self.detectedThreatListCtrl.InsertColumn(3,
                                                 "Status",
                                                 width=0.166 * width)

        self.font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.BOLD, False,
                            u'Consolas')
        self.prepareThreatList()

        sBox = wx.StaticBox(panel, label='', size=(width - 3, -1))
        sBoxsizer = wx.StaticBoxSizer(sBox, wx.VERTICAL)
        sBoxsizer.Add(self.detectedThreatListCtrl, 2, wx.ALL | wx.EXPAND, 2)

        self.btnIgnore = wx.Button(panel, wx.ID_YES, "Ignore All")
        self.btnIgnore.Bind(wx.EVT_BUTTON, self.OnVirusIgnoreAll,
                            self.btnIgnore)
        self.btnHeal = wx.Button(panel, wx.ID_YES, "Heal All")
        self.btnHeal.Bind(wx.EVT_BUTTON, self.OnVirusHealAll, self.btnHeal)
        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(self.btnIgnore,
                   flag=wx.ALL | wx.CENTER | wx.EXPAND,
                   border=4)
        hSizer.Add(self.btnHeal, flag=wx.ALL | wx.CENTER | wx.EXPAND, border=4)

        vSizer = wx.BoxSizer(wx.VERTICAL)
        vSizer.Add(threatDetectedInfo, flag=wx.EXPAND | wx.ALL | wx.CENTER)
        vSizer.Add(sBoxsizer, 1)
        vSizer.Add(hSizer, flag=wx.CENTER | wx.ALL | wx.EXPAND)
        panel.SetSizer(vSizer, wx.EXPAND | wx.ALL)
        self.Layout()
コード例 #7
0
    def __init__(self,
                 freq_corr=0,
                 avg_frames=1,
                 N_id_2=0,
                 N_id_1=134,
                 decim=16):
        grc_wxgui.top_block_gui.__init__(self, title="Sss Corr3 Gui")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.freq_corr = freq_corr
        self.avg_frames = avg_frames
        self.N_id_2 = N_id_2
        self.N_id_1 = N_id_1
        self.decim = decim

        ##################################################
        # Variables
        ##################################################
        self.vec_half_frame = vec_half_frame = 30720 * 5 / decim
        self.symbol_start = symbol_start = 144 / decim
        self.samp_rate = samp_rate = 30720e3 / decim
        self.rot = rot = 0
        self.noise_level = noise_level = 0
        self.fft_size = fft_size = 2048 / decim
        self.N_re = N_re = 62

        ##################################################
        # Blocks
        ##################################################
        _symbol_start_sizer = wx.BoxSizer(wx.VERTICAL)
        self._symbol_start_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_symbol_start_sizer,
            value=self.symbol_start,
            callback=self.set_symbol_start,
            label='symbol_start',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._symbol_start_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_symbol_start_sizer,
            value=self.symbol_start,
            callback=self.set_symbol_start,
            minimum=0,
            maximum=144 / decim,
            num_steps=144 / decim,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_symbol_start_sizer)
        _rot_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rot_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rot_sizer,
            value=self.rot,
            callback=self.set_rot,
            label='rot',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rot_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rot_sizer,
            value=self.rot,
            callback=self.set_rot,
            minimum=0,
            maximum=1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_rot_sizer)
        _noise_level_sizer = wx.BoxSizer(wx.VERTICAL)
        self._noise_level_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_noise_level_sizer,
            value=self.noise_level,
            callback=self.set_noise_level,
            label='noise_level',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._noise_level_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_noise_level_sizer,
            value=self.noise_level,
            callback=self.set_noise_level,
            minimum=0,
            maximum=10,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_noise_level_sizer)
        self.wxgui_scopesink2_0_1 = scopesink2.scope_sink_f(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=gr.gr_TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0_1.win)
        self.sss_equ_0 = sss_equ(N_id_2=0, )
        self.sss_corr3_gui_0 = sss_corr3_gui(
            decim=decim,
            N_id_1=N_id_1,
            N_id_2=N_id_2,
            avg_frames=avg_frames,
            slot_0_10=1,
        )
        self.gr_vector_to_stream_1 = gr.vector_to_stream(
            gr.sizeof_gr_complex * 1, fft_size)
        self.gr_vector_to_stream_0 = gr.vector_to_stream(
            gr.sizeof_gr_complex * 1, fft_size)
        self.gr_vector_source_x_0_1 = gr.vector_source_c(
            (gen_sss_fd(N_id_1, N_id_2, fft_size).get_sss(False)), True,
            fft_size)
        self.gr_vector_source_x_0_0_1 = gr.vector_source_c(
            (gen_pss_fd(N_id_2, fft_size, False).get_data()), True, fft_size)
        self.gr_vector_source_x_0_0 = gr.vector_source_c(
            (gen_pss_fd(N_id_2, fft_size, False).get_data()), True, fft_size)
        self.gr_vector_source_x_0 = gr.vector_source_c(
            (gen_sss_fd(N_id_1, N_id_2, fft_size).get_sss(True)), True,
            fft_size)
        self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate)
        self.gr_stream_to_vector_0_0 = gr.stream_to_vector(
            gr.sizeof_gr_complex * 1, N_re)
        self.gr_stream_to_vector_0 = gr.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_size)
        self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN,
                                                     noise_level, 0)
        self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc(
            (0.005 * exp(rot * 2 * numpy.pi * 1j), ))
        self.gr_keep_m_in_n_1 = gr.keep_m_in_n(gr.sizeof_gr_complex, fft_size,
                                               fft_size + 144 / decim,
                                               symbol_start)
        self.gr_keep_m_in_n_0 = gr.keep_m_in_n(gr.sizeof_gr_complex, N_re,
                                               fft_size, (fft_size - N_re) / 2)
        self.gr_interleave_0 = gr.interleave(gr.sizeof_gr_complex * fft_size)
        self.gr_file_source_0 = gr.file_source(
            gr.sizeof_gr_complex * 1,
            "/home/user/git/gr-lte/gr-lte/test/foo_pss0_sss_in.cfile", True)
        self.gr_fft_vxx_1 = gr.fft_vcc(fft_size, False,
                                       (window.blackmanharris(1024)), True, 1)
        self.gr_fft_vxx_0 = gr.fft_vcc(fft_size, True,
                                       (window.blackmanharris(1024)), True, 1)
        self.gr_deinterleave_0 = gr.deinterleave(gr.sizeof_gr_complex * N_re)
        self.gr_channel_model_0 = gr.channel_model(
            noise_voltage=0.005 * noise_level,
            frequency_offset=0.0,
            epsilon=1,
            taps=(0.005 * exp(rot * 2 * numpy.pi * 1j), ),
            noise_seed=0,
        )
        self.gr_add_xx_0 = gr.add_vcc(1)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            fft_size, fft_size + 144 / decim)
        self.blks2_selector_0_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=2,
            num_outputs=1,
            input_index=1,
            output_index=0,
        )
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=3,
            num_outputs=2,
            input_index=0,
            output_index=1,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_stream_to_vector_0, 0), (self.gr_fft_vxx_0, 0))
        self.connect((self.gr_stream_to_vector_0_0, 0),
                     (self.gr_deinterleave_0, 0))
        self.connect((self.gr_keep_m_in_n_0, 0),
                     (self.gr_stream_to_vector_0_0, 0))
        self.connect((self.gr_vector_to_stream_0, 0),
                     (self.gr_keep_m_in_n_0, 0))
        self.connect((self.gr_fft_vxx_0, 0), (self.gr_vector_to_stream_0, 0))
        self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1))
        self.connect((self.gr_add_xx_0, 0), (self.gr_multiply_const_vxx_0, 0))
        self.connect((self.gr_throttle_0, 0), (self.gr_stream_to_vector_0, 0))
        self.connect((self.blks2_selector_0, 0), (self.gr_channel_model_0, 0))
        self.connect((self.blks2_selector_0, 1), (self.gr_add_xx_0, 0))
        self.connect((self.gr_channel_model_0, 0),
                     (self.blks2_selector_0_0, 0))
        self.connect((self.gr_multiply_const_vxx_0, 0),
                     (self.blks2_selector_0_0, 1))
        self.connect((self.gr_keep_m_in_n_1, 0), (self.blks2_selector_0, 2))
        self.connect((self.gr_vector_to_stream_1, 0),
                     (self.blks2_selector_0, 1))
        self.connect((self.gr_fft_vxx_1, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.gr_keep_m_in_n_1, 0))
        self.connect((self.gr_file_source_0, 0), (self.blks2_selector_0, 0))
        self.connect((self.gr_fft_vxx_1, 0), (self.gr_vector_to_stream_1, 0))
        self.connect((self.gr_interleave_0, 0), (self.gr_fft_vxx_1, 0))
        self.connect((self.blks2_selector_0_0, 0), (self.gr_throttle_0, 0))
        self.connect((self.gr_vector_source_x_0_0, 0),
                     (self.gr_interleave_0, 1))
        self.connect((self.gr_vector_source_x_0_0_1, 0),
                     (self.gr_interleave_0, 3))
        self.connect((self.gr_vector_source_x_0, 0), (self.gr_interleave_0, 0))
        self.connect((self.gr_vector_source_x_0_1, 0),
                     (self.gr_interleave_0, 2))
        self.connect((self.gr_deinterleave_0, 0), (self.sss_equ_0, 1))
        self.connect((self.gr_deinterleave_0, 1), (self.sss_equ_0, 0))
        self.connect((self.sss_corr3_gui_0, 0), (self.wxgui_scopesink2_0_1, 0))
        self.connect((self.sss_equ_0, 0), (self.sss_corr3_gui_0, 0))
コード例 #8
0
    def __init__(self):
        wx.Frame.__init__(self, None, id = wx.ID_ANY, 
            title = u"PubRansack", 
            pos = wx.DefaultPosition, size = wx.Size( 1024,535 ), 
            style = wx.DEFAULT_FRAME_STYLE ^ (wx.RESIZE_BORDER|wx.MAXIMIZE_BOX))
        
        self.panel_sch = sView(self)
        self.panel_baz = bView(self)
        self.panel_baz.Hide()
        
        self.SetSizeHintsSz( wx.Size( -1,-1 ), wx.DefaultSize )
        
        firstSizer = wx.BoxSizer( wx.VERTICAL )
        
        firstSizer.Add(self.panel_sch, 1, wx.EXPAND)
        firstSizer.Add(self.panel_baz, 1, wx.EXPAND)
        
        self.SetSizer( firstSizer )
        self.Layout()
        
        #StatusBar
        self.statusbar = self.CreateStatusBar( 1, wx.ST_SIZEGRIP, wx.ID_ANY )
        Publisher().subscribe(self.change_statusbar, 'change_statusbar')
        
        ico = wx.Icon('icon/ikona.ico', wx.BITMAP_TYPE_ICO)
        self.SetIcon(ico)
        
        self.m_menubar1 = wx.MenuBar( 0 )
        self.m_menu1 = wx.Menu()
        self.m_menuItem1 = wx.MenuItem( self.m_menu1, 21, u"Wyszukiwarka", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem1.SetBitmap( wx.Bitmap( u"icon/search16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu1.AppendItem( self.m_menuItem1 )
        
        self.m_menuItem2 = wx.MenuItem( self.m_menu1, 22, u"Baza danych", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem2.SetBitmap( wx.Bitmap( u"icon/base16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu1.AppendItem( self.m_menuItem2 )
        
        self.m_menu1.AppendSeparator()
        
        self.m_menuItem6 = wx.MenuItem( self.m_menu1, 23, u"Wyjdź", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem6.SetBitmap( wx.Bitmap( u"icon/exit16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu1.AppendItem( self.m_menuItem6 )
        
        self.m_menubar1.Append( self.m_menu1, u"Widok" ) 
        
        self.m_menu2 = wx.Menu()
        self.m_menuItem20 = wx.MenuItem( self.m_menu2, 24, u"Wczytaj z pliku", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem20.SetBitmap( wx.Bitmap( u"icon/fileopen16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu2.AppendItem( self.m_menuItem20 )
        
        self.m_menuItem21 = wx.MenuItem( self.m_menu2, 25, u"Przywróc ostatnio wybrane", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem21.SetBitmap( wx.Bitmap( u"icon/back16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu2.AppendItem( self.m_menuItem21 )
        
        self.m_menuItem22 = wx.MenuItem( self.m_menu2, 26, u"Czyść listę", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem22.SetBitmap( wx.Bitmap( u"icon/clear16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu2.AppendItem( self.m_menuItem22 )
        
        self.m_menu2.AppendSeparator()
        
        self.m_menuItem23 = wx.MenuItem( self.m_menu2, 27, u"Edytuj i Zapisz", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem23.SetBitmap( wx.Bitmap( u"icon/add16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu2.AppendItem( self.m_menuItem23 )
        
        self.m_menuItem24 = wx.MenuItem( self.m_menu2, 28, u"Zapisz wszystkie", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem24.SetBitmap( wx.Bitmap( u"icon/addm16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu2.AppendItem( self.m_menuItem24 )
        
        self.m_menuItem25 = wx.MenuItem( self.m_menu2, 29, u"Wyświetl publikację", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem25.SetBitmap( wx.Bitmap( u"icon/browser16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu2.AppendItem( self.m_menuItem25 )
        
        self.m_menubar1.Append( self.m_menu2, u"Wyszukiwarka" ) 
        
        self.m_menu3 = wx.Menu()
        self.m_menuItem7 = wx.MenuItem( self.m_menu3, 30, u"Zarządzanie Autorami", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem7.SetBitmap( wx.Bitmap( u"icon/autor16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu3.AppendItem( self.m_menuItem7 )
        
        self.m_menuItem8 = wx.MenuItem( self.m_menu3, 31, u"Zarządzanie Grupami", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem8.SetBitmap( wx.Bitmap( u"icon/grupa16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu3.AppendItem( self.m_menuItem8 )
        
        self.m_menuItem9 = wx.MenuItem( self.m_menu3, 32, u"Zarządzanie Publikacjami", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem9.SetBitmap( wx.Bitmap( u"icon/pub16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu3.AppendItem( self.m_menuItem9 )
        
        self.m_menuItem10 = wx.MenuItem( self.m_menu3, 33, u"Zarządzanie Wydawcami", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem10.SetBitmap( wx.Bitmap( u"icon/journal16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu3.AppendItem( self.m_menuItem10 )
        
        self.m_menu3.AppendSeparator()
        
        self.m_menu11 = wx.Menu()
        self.m_menuItem11 = wx.MenuItem( self.m_menu11, 34, u"Edytuj wybrane", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem11.SetBitmap( wx.Bitmap( u"icon/edit16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu11.AppendItem( self.m_menuItem11 )
        
        self.m_menuItem12 = wx.MenuItem( self.m_menu11, 35, u"Usuń wybrane", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem12.SetBitmap( wx.Bitmap( u"icon/delete16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu11.AppendItem( self.m_menuItem12 )
        
        self.m_menuItem13 = wx.MenuItem( self.m_menu11, 36, u"Wyczyść listę", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem13.SetBitmap( wx.Bitmap( u"icon/clear16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu11.AppendItem( self.m_menuItem13 )
        
        self.m_menuItem14 = wx.MenuItem( self.m_menu11, 37, u"Wyświetl publikację", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem14.SetBitmap( wx.Bitmap( u"icon/browser16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu11.AppendItem( self.m_menuItem14 )
        
        self.m_menuItem15 = wx.MenuItem( self.m_menu11, 38, u"Wyświetl cytowania", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem15.SetBitmap( wx.Bitmap( u"icon/globe16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu11.AppendItem( self.m_menuItem15 )
        
        self.m_menuItem16 = wx.MenuItem( self.m_menu11, 39, u"Połącz publikacje", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem16.SetBitmap( wx.Bitmap( u"icon/cite16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu11.AppendItem( self.m_menuItem16 )
        
        self.m_menu3.AppendSubMenu( self.m_menu11, u"Edycja" )
        
        self.m_menu31 = wx.Menu()
        self.m_menuItem17 = wx.MenuItem( self.m_menu31, 40, u"Generuj HTML", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem17.SetBitmap( wx.Bitmap( u"icon/www16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu31.AppendItem( self.m_menuItem17 )
        
        self.m_menuItem18 = wx.MenuItem( self.m_menu31, 41, u"Generuj Bibtex", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem18.SetBitmap( wx.Bitmap( u"icon/txt16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu31.AppendItem( self.m_menuItem18 )
        
        self.m_menu3.AppendSubMenu( self.m_menu31, u"Generowanie" )
        
        self.m_menu3.AppendSeparator()
        
        self.m_menuItem26 = wx.MenuItem( self.m_menu3, 43, u"Utwórz kopie", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem26.SetBitmap( wx.Bitmap( u"icon/backup16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu3.AppendItem( self.m_menuItem26 )
        
        self.m_menuItem27 = wx.MenuItem( self.m_menu3, 44, u"Wczytaj kopie", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem27.SetBitmap( wx.Bitmap( u"icon/replace16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu3.AppendItem( self.m_menuItem27 )
        
        self.m_menubar1.Append( self.m_menu3, u"Baza danych" ) 
        
        self.m_menu5 = wx.Menu()
        self.m_menuItem19 = wx.MenuItem( self.m_menu5, 42, u"O Programie", wx.EmptyString, wx.ITEM_NORMAL )
        self.m_menuItem19.SetBitmap( wx.Bitmap( u"icon/about16.png", wx.BITMAP_TYPE_ANY ) )
        self.m_menu5.AppendItem( self.m_menuItem19 )
        
        self.m_menubar1.Append( self.m_menu5, u"Pomoc" ) 
        
        self.SetMenuBar( self.m_menubar1 )
        
        self.m_toolBar1 = self.CreateToolBar( wx.TB_FLAT|wx.TB_HORIZONTAL, wx.ID_ANY ) 
        stool = self.m_toolBar1.AddLabelTool( 1, u"tool", wx.Bitmap( u"icon/search.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_RADIO, u'Wyszukiwarka', wx.EmptyString ) 
        btool = self.m_toolBar1.AddLabelTool( 2, u"tool", wx.Bitmap( u"icon/base.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_RADIO, u'Baza dancyh', wx.EmptyString ) 
        self.m_toolBar1.AddSeparator()
        addaut = self.m_toolBar1.AddLabelTool( 3, u"tool", wx.Bitmap( u"icon/autor.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Zarządzanie Autorami', wx.EmptyString ) 
        addgru = self.m_toolBar1.AddLabelTool( 4, u"tool", wx.Bitmap( u"icon/grupa.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Zarządzanie Grupami', wx.EmptyString ) 
        addpub = self.m_toolBar1.AddLabelTool( 5, u"tool", wx.Bitmap( u"icon/pub.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Zarządzanie Publikacjami', wx.EmptyString ) 
        addwyd = self.m_toolBar1.AddLabelTool( 6, u"tool", wx.Bitmap( u"icon/journal.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Zarządzanie Wydawcami', wx.EmptyString ) 
        self.m_toolBar1.AddSeparator()
        backup = self.m_toolBar1.AddLabelTool( 45, u"tool", wx.Bitmap( u"icon/backup.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Utworzenie kopii zapasowej bazy danych', wx.EmptyString ) 
        replace = self.m_toolBar1.AddLabelTool( 46, u"tool", wx.Bitmap( u"icon/replace.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Wczytanie kopii zapasowej bazy danych', wx.EmptyString ) 
        self.m_toolBar1.AddSeparator()
        raport = self.m_toolBar1.AddLabelTool( 7, u"tool", wx.Bitmap( u"icon/fileopen.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Wczytaj pobrane publikacje', wx.EmptyString ) 
        backlist = self.m_toolBar1.AddLabelTool( 8, u"tool", wx.Bitmap( u"icon/back.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Przywróć ostatnie publikacje', wx.EmptyString ) 
        clear = self.m_toolBar1.AddLabelTool( 9, u"tool", wx.Bitmap( u"icon/clear.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Wyczyść listę publikacji', wx.EmptyString ) 
        addrec = self.m_toolBar1.AddLabelTool( 10, u"tool", wx.Bitmap( u"icon/add.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Edytuj i Zapisz wybrane publikacje', wx.EmptyString ) 
        addrecm = self.m_toolBar1.AddLabelTool( 11, u"tool", wx.Bitmap( u"icon/addm.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Dodaj wszystkie wybrane publikacje', wx.EmptyString ) 
        viewpub = self.m_toolBar1.AddLabelTool( 12, u"tool", wx.Bitmap( u"icon/browser.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Wyświetl wybrane publikacje', wx.EmptyString ) 
        self.m_toolBar1.AddSeparator()
        editrec = self.m_toolBar1.AddLabelTool( 13, u"tool", wx.Bitmap( u"icon/edit.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Edytuj wybrane publikacje w bazie', wx.EmptyString ) 
        delrec = self.m_toolBar1.AddLabelTool( 14, u"tool", wx.Bitmap( u"icon/delete.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Usuń wybrane publikacje z bazy', wx.EmptyString ) 
        clearbase = self.m_toolBar1.AddLabelTool( 15, u"tool", wx.Bitmap( u"icon/clear.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Wyczyść listę publikacji', wx.EmptyString ) 
        viewpubbase = self.m_toolBar1.AddLabelTool( 16, u"tool", wx.Bitmap( u"icon/browser.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Wyświetl wybrane publikacje', wx.EmptyString ) 
        viewcitbase = self.m_toolBar1.AddLabelTool( 17, u"tool", wx.Bitmap( u"icon/globe.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Wyświetl cytowania wybranych publikacji', wx.EmptyString ) 
        cit = self.m_toolBar1.AddLabelTool( 18, u"tool", wx.Bitmap( u"icon/cite.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Zarządzanie/Łączenie wybranych publikacji', wx.EmptyString ) 
        self.m_toolBar1.AddSeparator()
        gh = self.m_toolBar1.AddLabelTool( 19, u"tool", wx.Bitmap( u"icon/www.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Generowanie pliku HTML z wybranych publikacji', wx.EmptyString ) 
        gb = self.m_toolBar1.AddLabelTool( 20, u"tool", wx.Bitmap( u"icon/txt.png", wx.BITMAP_TYPE_ANY ), wx.NullBitmap, wx.ITEM_NORMAL, u'Generowanie pliku Bibtex z wybranych publikacji', wx.EmptyString ) 
        
        self.m_toolBar1.Realize()
        
        self.Centre( wx.BOTH )
        
        ## Visibility
        self.m_toolBar1.EnableTool(13, False)
        self.m_toolBar1.EnableTool(14, False)
        self.m_toolBar1.EnableTool(15, False)
        self.m_toolBar1.EnableTool(16, False)
        self.m_toolBar1.EnableTool(17, False)
        self.m_toolBar1.EnableTool(18, False)
        self.m_toolBar1.EnableTool(19, False)
        self.m_toolBar1.EnableTool(20, False)
#        self.m_toolBar1.EnableTool(21, False)
        self.m_menu11.Enable(34, False)
        self.m_menu11.Enable(35, False)
        self.m_menu11.Enable(36, False)
        self.m_menu11.Enable(37, False)
        self.m_menu11.Enable(38, False)
        self.m_menu11.Enable(39, False)
        self.m_menu31.Enable(40, False)
        self.m_menu31.Enable(41, False)
        
        ##Bindowanie
        ##Menubar
        ##Panele
        self.Bind(wx.EVT_MENU, self.SearchPanel, self.m_menuItem1)
        self.Bind(wx.EVT_MENU, self.BasePanel, self.m_menuItem2)
        self.Bind(wx.EVT_MENU, self.Close, self.m_menuItem6)
        
        ##Baza danych
        self.Bind(wx.EVT_MENU, self.onAddPub, self.m_menuItem9)
        self.Bind(wx.EVT_MENU, self.onAddGroup, self.m_menuItem8)
        self.Bind(wx.EVT_MENU, self.onAddJournal, self.m_menuItem10)
        self.Bind(wx.EVT_MENU, self.onEditAuthor, self.m_menuItem7)
        ##Edycja
        self.Bind(wx.EVT_MENU, self.EditDataBase, self.m_menuItem11)
        self.Bind(wx.EVT_MENU, self.DeleteMultiDataBase, self.m_menuItem12)
        self.Bind(wx.EVT_MENU, self.ClearDataBase, self.m_menuItem13)
        self.Bind(wx.EVT_MENU, self.OpenBaseLink, self.m_menuItem14)
        self.Bind(wx.EVT_MENU, self.OpenBaseCiteLink, self.m_menuItem15)
        self.Bind(wx.EVT_MENU, self.GetCit, self.m_menuItem16)
        ##Generowanie
        self.Bind(wx.EVT_MENU, self.GHtml, self.m_menuItem17)
        self.Bind(wx.EVT_MENU, self.GBibtex, self.m_menuItem18)
        ##Kopia bazy
        self.Bind(wx.EVT_MENU, self.saveDatabase, self.m_menuItem26)
        self.Bind(wx.EVT_MENU, self.GetDatabase, self.m_menuItem27)
        
        ##Wyszukiwanie
        self.Bind(wx.EVT_MENU, self.GetRaport, self.m_menuItem20)
        self.Bind(wx.EVT_MENU, self.BackList, self.m_menuItem21)
        self.Bind(wx.EVT_MENU, self.ClearDataSearch, self.m_menuItem22)
        self.Bind(wx.EVT_MENU, self.AddOneData, self.m_menuItem23)
        self.Bind(wx.EVT_MENU, self.AddMultiData, self.m_menuItem24)
        self.Bind(wx.EVT_MENU, self.OpenBrowserLink, self.m_menuItem25)
        
        ##O programie
        self.Bind(wx.EVT_MENU, self.viewAbout, self.m_menuItem19)
        
        ##Toolbar
        ## Panele
        self.Bind( wx.EVT_TOOL, self.SearchPanel, stool )
        self.Bind( wx.EVT_TOOL, self.BasePanel, btool )
        
        ##Edycja wartosci w bazie
        self.Bind( wx.EVT_TOOL, self.onAddPub, addpub ) #zarzadzanie publikacjami
        self.Bind( wx.EVT_TOOL, self.onAddGroup, addgru ) #zarzadzanie grupami
        self.Bind( wx.EVT_TOOL, self.onAddJournal, addwyd ) #zarzadzanie wydawcami
        self.Bind( wx.EVT_TOOL, self.onEditAuthor, addaut ) #zarzadzanie autorami
        
        ##Narzedzia dla wyszukiwania
        self.Bind( wx.EVT_TOOL, self.AddOneData, addrec ) #dodawanie jednego rekordu
        self.Bind( wx.EVT_TOOL, self.AddMultiData, addrecm ) #dodawanie wielu rekordów
        self.Bind( wx.EVT_TOOL, self.ClearDataSearch, clear ) #czyszczenie lsity
        self.Bind( wx.EVT_TOOL, self.BackList, backlist ) #przywracanie ostatnio pobranej listy
        self.Bind( wx.EVT_TOOL, self.OpenBrowserLink, viewpub ) #wyswietla publikacje w przegladarce
        self.Bind( wx.EVT_TOOL, self.GetRaport, raport )
        
        ##Narzedzia dla bazy dancyh
        self.Bind( wx.EVT_TOOL, self.DeleteMultiDataBase, delrec ) #usuwanie zaznaczonych rekordow
        self.Bind( wx.EVT_TOOL, self.ClearDataBase, clearbase ) #czyszczenie listy
        self.Bind( wx.EVT_TOOL, self.EditDataBase, editrec ) #edytowanie wybranych rekordów
        self.Bind( wx.EVT_TOOL, self.OpenBaseLink, viewpubbase ) #otwieranie publikacji w przegladarce
        self.Bind( wx.EVT_TOOL, self.GetCit, cit ) #otwieranie menadzera łaczenia publikacji
        self.Bind( wx.EVT_TOOL, self.OpenBaseCiteLink, viewcitbase ) #otwieranie cytowan w przegladarce
        self.Bind( wx.EVT_TOOL, self.GHtml, gh ) #generowanie html
        self.Bind( wx.EVT_TOOL, self.GBibtex, gb ) #generowanie bibtex
        self.Bind( wx.EVT_TOOL, self.saveDatabase, backup )
        self.Bind( wx.EVT_TOOL, self.GetDatabase, replace )
コード例 #9
0
    def InitUI(self):
        """ Init the user interface
		"""

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

        icon = wx.EmptyIcon() if wx.VERSION_STRING < '4.0' else wx.Icon()
        icon.CopyFromBitmap(
            wx.Bitmap(os.path.join(ICON_PATH_16_16, "properties.png"),
                      wx.BITMAP_TYPE_ANY))
        self.SetIcon(icon)

        panel = wx.Panel(self)
        vbox = wx.BoxSizer(wx.VERTICAL)

        ### Add a toolbar in order to add, delete, import, export and have help on the user of constant.
        tb = wx.ToolBar(panel)
        vbox.Add(tb, 0, wx.EXPAND)

        tb.SetToolBitmapSize((16, 16))

        tb.AddTool(ID_ADD,
                   "",
                   wx.Bitmap(os.path.join(ICON_PATH, 'comment_add.png')),
                   shortHelp=_('New constant'))
        tb.AddTool(ID_REMOVE,
                   "",
                   wx.Bitmap(os.path.join(ICON_PATH, 'comment_remove.png')),
                   shortHelp=_('Delete constant'))
        tb.AddTool(ID_EXPORT,
                   "",
                   wx.Bitmap(os.path.join(ICON_PATH, 'export.png')),
                   shortHelp=_('Export constants into file'))
        tb.AddTool(ID_IMPORT,
                   "",
                   wx.Bitmap(os.path.join(ICON_PATH, 'import.png')),
                   wx.NullBitmap,
                   shortHelp=_('Import constants from file'))
        tb.AddTool(ID_HELP,
                   "",
                   wx.Bitmap(os.path.join(ICON_PATH, 'info.png')),
                   wx.NullBitmap,
                   shortHelp=_('Help'))

        tb.Realize()

        self._grid = wx.grid.Grid(panel)
        self._grid.AutoSizeColumns(True)
        self._grid.CreateGrid(1, 2)
        self._grid.SetColLabelValue(0, _("Name"))
        self._grid.SetColSize(0, 200)
        self._grid.SetColLabelValue(1, _("Value"))
        self._grid.SetColSize(1, 200)

        ### label column is not visible
        self._grid.SetRowLabelSize(0)

        vbox.Add(self._grid, 1, wx.EXPAND | wx.ALL, 0)

        vbox.Add((-1, 15))

        self._button_ok = wx.Button(panel, wx.ID_OK, size=(70, 30))
        self._button_cancel = wx.Button(panel, wx.ID_CANCEL, size=(70, 30))

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(self._button_cancel)
        hbox.Add(self._button_ok, flag=wx.LEFT | wx.BOTTOM, border=5)

        vbox.Add(hbox,
                 0,
                 flag=wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL
                 | wx.ADJUST_MINSIZE,
                 border=10)

        #	From http://docs.wxwidgets.org/trunk/overview_windowsizing.html, wxWidgets provides two main methods for sizing:
        #
        #   Fit() sets the size of a window to fit around its children.
        #	The size of each children is added and then this parent window changes its size to fit them all.
        #   Layout() the opposite. The children will change their size, according to sizer rules, so they can fit into available space of their parent.
        #	[...] is what is called by the default EVT_SIZE handler for container windows

        #	Because a grid can have thousands of rows/cols its size can be huge.
        #	Don't try to tell the parent to fit around it.
        #	You better set max and min sizes for the grid (or its sizer) and then use Fit() or Layout() each time you change number of rows/cols or their sizes.

        panel.SetSizerAndFit(vbox)
        #self.SetAutoLayout(True)
        #self.Fit()

        self.__set_events()

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

        self.Center()
コード例 #10
0
    def __init_ctrls(self, parent):
        wx.Dialog.__init__(self,
                           id=wxID_ABOUT,
                           name=u'About',
                           parent=parent,
                           style=wx.DEFAULT_DIALOG_STYLE,
                           title=_(u"About Metamorphose"))
        self.SetIcon(wx.Icon(utils.icon_path(u'about.ico'),
                             wx.BITMAP_TYPE_ICO))

        fontParams = app.fontParams
        fontSize = fontParams['size']
        fontFamily = fontParams['family']
        fontStyle = fontParams['style']

        self.SetFont(
            wx.Font(fontSize + 1, fontFamily, fontStyle, wx.NORMAL, False,
                    u'Times New Roman'))
        self.Center(wx.HORIZONTAL | wx.VERTICAL)
        self.SetThemeEnabled(True)

        self.greet = wx.StaticText(id=wxID_ABOUTGREET,
                                   label=u"Métamorphose 2",
                                   name=u'greet',
                                   parent=self)
        self.greet.SetFont(
            wx.Font(fontSize + 4, fontFamily, fontStyle, wx.BOLD, False))

        self.CLOSE = wx.BitmapButton(
            id=wxID_ABOUTCLOSE,
            bitmap=wx.Bitmap(utils.icon_path(u'metamorphose128.png'),
                             wx.BITMAP_TYPE_PNG),
            name=u'CLOSE',
            parent=self,
            style=wx.BU_AUTODRAW)
        self.CLOSE.SetToolTipString(_(u"Click here to exit"))
        self.CLOSE.Bind(wx.EVT_BUTTON,
                        self.on_close_button,
                        id=wxID_ABOUTCLOSE)

        self.copyright = wx.StaticText(
            id=wxID_ABOUTCOPYRIGHT,
            label=u"Copyright © 2006-2015 Ianaré Sévi",
            name=u'copyright',
            parent=self)
        self.copyright.SetFont(
            wx.Font(fontSize + 2, fontFamily, fontStyle, wx.BOLD, False))

        self.version = wx.StaticText(id=wxID_ABOUTVERSION,
                                     label=_(u"Version: %s") % app.version,
                                     name=u'version',
                                     parent=self)
        self.version.SetFont(
            wx.Font(fontSize + 2, fontFamily, fontStyle, wx.BOLD, False))

        self.wxVersion = wx.StaticText(
            id=wxID_ABOUTWXVERSION,
            label=_(u"Using Python %s, wxPython %s") %
            (platform.python_version(), self._get_wxversion()),
            name=u'version',
            parent=self)
        self.wxVersion.SetFont(
            wx.Font(fontSize + 1, fontFamily, fontStyle, wx.NORMAL, False))

        self.link = hl.HyperLinkCtrl(
            self,
            wxID_ABOUTLINK,
            _(u"Metamorphose Home Page"),
            URL=u'http://file-folder-ren.sourceforge.net/',
            style=0)

        self.bugReport = hl.HyperLinkCtrl(
            self,
            wxID_ABOUTLINK,
            _(u"GitHub Project Page"),
            URL=u'https://github.com/metamorphose/metamorphose2')
        self.bugReport.Show(True)

        self.donateButton = wx.Button(id=wxID_PANELDONATEBUTTON,
                                      label=_(u"Donate"),
                                      name=u'donateButton',
                                      parent=self)
        self.donateButton.SetFont(
            wx.Font(fontSize + 4, fontFamily, fontStyle, wx.BOLD, False,
                    u'Times New Roman'))
        self.donateButton.Bind(wx.EVT_BUTTON,
                               self.on_donate_button,
                               id=wxID_PANELDONATEBUTTON)

        self.donate = hl.HyperLinkCtrl(
            self,
            wxID_ABOUTDONATE,
            _(u"Donate"),
            URL=u'http://sourceforge.net/donate/index.php?group_id=146403')
        self.donate.Show(False)

        self.licenseButton = wx.Button(id=wxID_PANELLICENSEBUTTON,
                                       label=_(u"License"),
                                       name=u'licenseButton',
                                       parent=self)
        self.licenseButton.Bind(wx.EVT_BUTTON,
                                self.show_small_help,
                                id=wxID_PANELLICENSEBUTTON)

        self.creditsButton = wx.Button(id=wxID_PANELCREDITSBUTTON,
                                       label=_(u"Credits"),
                                       name=u'licenseButton',
                                       parent=self)
        self.creditsButton.Bind(wx.EVT_BUTTON,
                                self.show_small_help,
                                id=wxID_PANELCREDITSBUTTON)
コード例 #11
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.ntaps = ntaps = 11 * nfilts * sps
        self.excess_bw = excess_bw = 0.4
        self.txtaps = txtaps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, excess_bw, ntaps)
        self.timing_bw = timing_bw = 2 * pi / 100
        self.samp_rate = samp_rate = 320e3
        self.rx_taps = rx_taps = filter.firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, excess_bw, ntaps)
        self.const_points = const_points = 8

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate / sps,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate / sps,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(sps,
                                                             taps=(txtaps),
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.iir_filter_xxx_1 = filter.iir_filter_ffd(([1.0001, -1]),
                                                      ([-1, 1]), True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd(([10e-3]),
                                                      ([-1, 990e-3]), True)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_bw, (rx_taps), nfilts, 16, 1.5, 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            ((1 + 0j), (0.707 + 0.707j), (0 + 1j), (-0.707 + 0.707j),
             (-1 + 0j), (-0.707 - 0.707j), (0 - 1j), (0.707 - 0.707j)), 1)
        self.blocks_vco_c_0_0 = blocks.vco_c(samp_rate / sps, -5, 1)
        self.blocks_vco_c_0 = blocks.vco_c(samp_rate / sps, samp_rate / sps, 1)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_float * 1,
                                                     "127.0.0.1", 12345, 1472,
                                                     True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1,
                                                 "127.0.0.1", 12345, 1472,
                                                 True)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                   samp_rate, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_multiply_xx_4 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_3 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (0.125, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.125, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float * 1, 500)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_complex_to_arg_1 = blocks.complex_to_arg(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, 10e3, 1, 0)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, const_points, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_arg_1, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_delay_0_0, 0), (self.iir_filter_xxx_1, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_vco_c_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.blocks_multiply_xx_3, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 0))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 1))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 2))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 3))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 4))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 5))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 6))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 7))
        self.connect((self.blocks_multiply_xx_4, 0),
                     (self.blocks_complex_to_arg_1, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_udp_source_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_vco_c_0_0, 0),
                     (self.blocks_multiply_xx_3, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 2))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 3))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 4))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 5))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 6))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 7))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.iir_filter_xxx_1, 0), (self.blocks_vco_c_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_throttle_0, 0))
コード例 #12
0
ファイル: Audio_FMCW_1.py プロジェクト: tprasadtp/fmcw-audio
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Audio Fmcw 1")
        _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48e3
        self.mul_constant = mul_constant = 0
        self.frequency = frequency = 50
        self.delay_ms = delay_ms = 350

        ##################################################
        # Blocks
        ##################################################
        self._mul_constant_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.mul_constant,
        	callback=self.set_mul_constant,
        	label='mul_constant',
        	converter=forms.float_converter(),
        )
        self.Add(self._mul_constant_text_box)
        self._frequency_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.frequency,
        	callback=self.set_frequency,
        	label='frequency',
        	converter=forms.float_converter(),
        )
        self.Add(self._frequency_text_box)
        _delay_ms_sizer = wx.BoxSizer(wx.VERTICAL)
        self._delay_ms_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_delay_ms_sizer,
        	value=self.delay_ms,
        	callback=self.set_delay_ms,
        	label='delay_ms',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._delay_ms_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_delay_ms_sizer,
        	value=self.delay_ms,
        	callback=self.set_delay_ms,
        	minimum=0,
        	maximum=1000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_delay_ms_sizer)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_f(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=21,
        	ref_level=10,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=2014,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title='Waterfall Plot',
        )
        self.Add(self.wxgui_waterfallsink2_1.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title='Waterfall Plot',
        )
        self.Add(self.wxgui_waterfallsink2_0.win)
        self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
        self.fft_vxx_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)), True, 1)
        self.blocks_vector_to_stream_2 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 1024)
        self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_float*1, 512)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, 512)
        self.blocks_vector_source_x_1 = blocks.vector_source_c((0, 0, 0), True, 1, [])
        self.blocks_vco_c_0 = blocks.vco_c(samp_rate, math.pi, 1)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 512)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024)
        self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, (1024, 1))
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(1, 512, 0)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_xx_0 = blocks.multiply_const_ff(mul_constant)
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*512, 1)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex, 512, 1024, 512)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, delay_ms)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(512)
        self.audio_source_0 = audio.source(48000, '', True)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_SAW_WAVE, frequency, 1, 0)
        self.analog_const_source_x_1 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_1, 0), (self.blocks_stream_mux_0, 1))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.audio_source_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.audio_source_0, 0), (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_vco_c_0, 0))
        self.connect((self.blocks_keep_m_in_n_0, 0), (self.blocks_stream_to_vector_1, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_vector_to_stream_1, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_multiply_const_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_stream_mux_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_stream_mux_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_vector_source_x_1, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_multiply_const_xx_0, 0))
        self.connect((self.blocks_vector_to_stream_1, 0), (self.wxgui_waterfallsink2_1, 0))
        self.connect((self.blocks_vector_to_stream_2, 0), (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_2, 0))
        self.connect((self.hilbert_fc_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))
コード例 #13
0
 def test_taskbar1(self):
     icon = wx.adv.TaskBarIcon(wx.adv.TBI_DOCK)
     icon.SetIcon(wx.Icon(icoFile), "The tip string")
     self.assertTrue(icon.IsOk())
     icon.Destroy()
     self.myYield()
コード例 #14
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 500000
        self.m = m = 0.5

        ##################################################
        # Blocks
        ##################################################
        _m_sizer = wx.BoxSizer(wx.VERTICAL)
        self._m_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_m_sizer,
        	value=self.m,
        	callback=self.set_m,
        	label='m',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._m_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_m_sizer,
        	value=self.m,
        	callback=self.set_m,
        	minimum=0.01,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_m_sizer)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.message = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 10000, 1, 0)
        self.carrier = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 100000, 1, 0)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((m, ))
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_abs_xx_0 = blocks.abs_ff(1)
        self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass(
        	1/m, samp_rate, 5000, 15000, 100, firdes.WIN_HAMMING, 6.76))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.band_pass_filter_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_abs_xx_0, 0), (self.band_pass_filter_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_abs_xx_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.wxgui_scopesink2_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.carrier, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.carrier, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.message, 0), (self.blocks_multiply_const_vxx_0, 0))    
コード例 #15
0
ファイル: itemStats.py プロジェクト: XaviarOnassis/Pyfa
    def __init__(self,
                 victim,
                 fullContext=None,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 maximized=False):

        wx.Dialog.__init__(self,
                           gui.mainFrame.MainFrame.getInstance(),
                           wx.ID_ANY,
                           title="Item stats",
                           pos=pos,
                           size=size,
                           style=wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX
                           | wx.MAXIMIZE_BOX | wx.RESIZE_BORDER
                           | wx.SYSTEM_MENU)

        empty = getattr(victim, "isEmpty", False)

        if empty:
            self.Hide()
            self.Destroy()
            return

        srcContext = fullContext[0]
        try:
            itmContext = fullContext[1]
        except IndexError:
            itmContext = None
        item = getattr(victim, "item", None) if srcContext.lower() not in (
            "projectedcharge",
            "fittingcharge") else getattr(victim, "charge", None)
        if item is None:
            sMkt = Market.getInstance()
            item = sMkt.getItem(victim.ID)
            victim = None
        self.context = itmContext
        if item.iconID is not None:
            itemImg = BitmapLoader.getBitmap(item.iconID, "icons")
            if itemImg is not None:
                self.SetIcon(wx.Icon(itemImg))
        self.SetTitle(
            "%s: %s%s" %
            ("%s Stats" % itmContext if itmContext is not None else "Stats",
             item.name, " (%d)" % item.ID if config.debug else ""))

        self.SetMinSize((300, 200))
        # GTK has huge tab widgets, give it a bit more room
        if "wxGTK" in wx.PlatformInfo:
            self.SetSize((640, 600))
        else:
            self.SetSize((550, 500))
        # self.SetMaxSize((500, -1))
        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.container = ItemStatsContainer(self, victim, item, itmContext)
        self.mainSizer.Add(self.container, 1, wx.EXPAND)

        self.SetSizer(self.mainSizer)

        self.parentWnd = gui.mainFrame.MainFrame.getInstance()

        dlgsize = self.GetSize()
        psize = self.parentWnd.GetSize()
        ppos = self.parentWnd.GetPosition()

        ItemStatsDialog.counter += 1
        self.dlgOrder = ItemStatsDialog.counter

        counter = ItemStatsDialog.counter
        dlgStep = 30
        if counter * dlgStep > ppos.x + psize.width - dlgsize.x or counter * dlgStep > ppos.y + psize.height - dlgsize.y:
            ItemStatsDialog.counter = 1

        dlgx = ppos.x + counter * dlgStep
        dlgy = ppos.y + counter * dlgStep
        if pos == wx.DefaultPosition:
            self.SetPosition((dlgx, dlgy))
        else:
            self.SetPosition(pos)
        if maximized:
            self.Maximize(True)
        else:
            if size != wx.DefaultSize:
                self.SetSize(size)
        self.parentWnd.RegisterStatsWindow(self)

        self.Show()

        self.Bind(wx.EVT_CHAR_HOOK, self.kbEvent)
        self.Bind(wx.EVT_CLOSE, self.closeEvent)
        self.Bind(wx.EVT_ACTIVATE, self.OnActivate)
コード例 #16
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 44100
        self.Noise = Noise = 0.01
        self.Loudness = Loudness = 0.7
        self.Frequency = Frequency = 5000

        ##################################################
        # Blocks
        ##################################################
        _Noise_sizer = wx.BoxSizer(wx.VERTICAL)
        self._Noise_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_Noise_sizer,
        	value=self.Noise,
        	callback=self.set_Noise,
        	label="Noise",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._Noise_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_Noise_sizer,
        	value=self.Noise,
        	callback=self.set_Noise,
        	minimum=0.0,
        	maximum=1,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_Noise_sizer)
        _Loudness_sizer = wx.BoxSizer(wx.VERTICAL)
        self._Loudness_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_Loudness_sizer,
        	value=self.Loudness,
        	callback=self.set_Loudness,
        	label="Loudness",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._Loudness_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_Loudness_sizer,
        	value=self.Loudness,
        	callback=self.set_Loudness,
        	minimum=0.0,
        	maximum=1.0,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_Loudness_sizer)
        _Frequency_sizer = wx.BoxSizer(wx.VERTICAL)
        self._Frequency_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_Frequency_sizer,
        	value=self.Frequency,
        	callback=self.set_Frequency,
        	label="Frequency",
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._Frequency_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_Frequency_sizer,
        	value=self.Frequency,
        	callback=self.set_Frequency,
        	minimum=10,
        	maximum=20000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_Frequency_sizer)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=4.0,
        	sample_rate=samp_rate,
        	fft_size=2048,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.1,
        	title="FFT Plot",
        	peak_hold=True,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.audio_sink_0 = audio.sink(samp_rate, "", True)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, Frequency, Loudness, 0)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, Noise, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0))    
コード例 #17
0
    def _set_properties(self, version, revision):
        """Set frame properties"""
        self.SetTitle(_("GRASS GIS %s startup%s") % (version, revision))
        self.SetIcon(
            wx.Icon(os.path.join(globalvar.ICONDIR, "grass.ico"),
                    wx.BITMAP_TYPE_ICO))

        self.bstart.SetToolTip(_("Enter GRASS session"))
        self.bstart.Enable(False)
        self.bmapset.Enable(False)
        # this all was originally a choice, perhaps just mapset needed
        self.rename_location_button.Enable(False)
        self.delete_location_button.Enable(False)
        self.rename_mapset_button.Enable(False)
        self.delete_mapset_button.Enable(False)

        # set database
        if not self.gisdbase:
            # sets an initial path for gisdbase if nothing in GISRC
            if os.path.isdir(os.getenv("HOME")):
                self.gisdbase = os.getenv("HOME")
            else:
                self.gisdbase = os.getcwd()
        try:
            self.tgisdbase.SetValue(self.gisdbase)
        except UnicodeDecodeError:
            wx.MessageBox(parent=self,
                          caption=_("Error"),
                          message=_("Unable to set GRASS database. "
                                    "Check your locale settings."),
                          style=wx.OK | wx.ICON_ERROR | wx.CENTRE)

        self.OnSetDatabase(None)
        location = self.GetRCValue("LOCATION_NAME")
        if location == "<UNKNOWN>":
            return
        if not os.path.isdir(os.path.join(self.gisdbase, location)):
            location = None

        # list of locations
        self.UpdateLocations(self.gisdbase)
        try:
            self.lblocations.SetSelection(self.listOfLocations.index(location),
                                          force=True)
            self.lblocations.EnsureVisible(
                self.listOfLocations.index(location))
        except ValueError:
            sys.stderr.write(
                _("ERROR: Location <%s> not found\n") %
                self.GetRCValue("LOCATION_NAME"))
            if len(self.listOfLocations) > 0:
                self.lblocations.SetSelection(0, force=True)
                self.lblocations.EnsureVisible(0)
                location = self.listOfLocations[0]
            else:
                return

        # list of mapsets
        self.UpdateMapsets(os.path.join(self.gisdbase, location))
        mapset = self.GetRCValue("MAPSET")
        if mapset:
            try:
                self.lbmapsets.SetSelection(self.listOfMapsets.index(mapset),
                                            force=True)
                self.lbmapsets.EnsureVisible(self.listOfMapsets.index(mapset))
            except ValueError:
                sys.stderr.write(_("ERROR: Mapset <%s> not found\n") % mapset)
                self.lbmapsets.SetSelection(0, force=True)
                self.lbmapsets.EnsureVisible(0)
コード例 #18
0
    def __init__(self,
                 DC_filter_num_elements=4,
                 samp_rate_sink=8000,
                 lo_offset_freq=1e6,
                 highpass_cutoff_freq=0,
                 doppler_signal_bw=20,
                 rx_gain=30.5,
                 tx_amp=1,
                 max_num_of_targets=10,
                 angle=0,
                 speed_samp_rate=1,
                 lowpass_cutoff_freq=1700,
                 fft_len=pow(2, 20),
                 RF=2.49e9,
                 samp_rate=1e6,
                 threshold_dB=-70):
        grc_wxgui.top_block_gui.__init__(self,
                                         title="CW Radar Multiple Targets")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.DC_filter_num_elements = DC_filter_num_elements
        self.samp_rate_sink = samp_rate_sink
        self.lo_offset_freq = lo_offset_freq
        self.highpass_cutoff_freq = highpass_cutoff_freq
        self.doppler_signal_bw = doppler_signal_bw
        self.rx_gain = rx_gain
        self.tx_amp = tx_amp
        self.max_num_of_targets = max_num_of_targets
        self.angle = angle
        self.speed_samp_rate = speed_samp_rate
        self.lowpass_cutoff_freq = lowpass_cutoff_freq
        self.fft_len = fft_len
        self.RF = RF
        self.samp_rate = samp_rate
        self.threshold_dB = threshold_dB

        ##################################################
        # Variables
        ##################################################
        self.target_speed_vector = target_speed_vector = 0
        self.target_direction_vector = target_direction_vector = 0
        self.num_targets = num_targets = 0
        self.tx_amp_tuner = tx_amp_tuner = tx_amp
        self.threshold_dB_tuner = threshold_dB_tuner = threshold_dB
        self.speed_textbox = speed_textbox = target_speed_vector
        self.rx_gain_tuner = rx_gain_tuner = rx_gain
        self.num_targets_textbox = num_targets_textbox = num_targets
        self.max_num_of_targets_tuner = max_num_of_targets_tuner = max_num_of_targets
        self.lowpass_cutoff_freq_tuner = lowpass_cutoff_freq_tuner = lowpass_cutoff_freq
        self.highpass_cutoff_freq_tuner = highpass_cutoff_freq_tuner = highpass_cutoff_freq
        self.doppler_signal_bw_tuner = doppler_signal_bw_tuner = doppler_signal_bw
        self.direction_textbox = direction_textbox = target_direction_vector
        self.angle_tuner = angle_tuner = angle
        self.RF_tuner = RF_tuner = RF

        ##################################################
        # Blocks
        ##################################################
        _tx_amp_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_amp_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_tx_amp_tuner_sizer,
            value=self.tx_amp_tuner,
            callback=self.set_tx_amp_tuner,
            label="TX Signal Amp",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._tx_amp_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_tx_amp_tuner_sizer,
            value=self.tx_amp_tuner,
            callback=self.set_tx_amp_tuner,
            minimum=0,
            maximum=1,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_tx_amp_tuner_sizer, 0, 8, 1, 21)
        _threshold_dB_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_dB_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_threshold_dB_tuner_sizer,
            value=self.threshold_dB_tuner,
            callback=self.set_threshold_dB_tuner,
            label="Detected Target Threshold (dB)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._threshold_dB_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_threshold_dB_tuner_sizer,
            value=self.threshold_dB_tuner,
            callback=self.set_threshold_dB_tuner,
            minimum=-90,
            maximum=-30,
            num_steps=60,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_threshold_dB_tuner_sizer, 2, 0, 1, 8)
        self.speed_vector_probe = blocks.probe_signal_vf(max_num_of_targets)
        _rx_gain_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_gain_tuner_sizer,
            value=self.rx_gain_tuner,
            callback=self.set_rx_gain_tuner,
            label="USRP RX Gain (dB)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_gain_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_gain_tuner_sizer,
            value=self.rx_gain_tuner,
            callback=self.set_rx_gain_tuner,
            minimum=0,
            maximum=30.5 + 62,
            num_steps=185,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rx_gain_tuner_sizer, 0, 0, 1, 8)
        self.notebook = self.notebook = wx.Notebook(self.GetWin(),
                                                    style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook),
                              "FFT CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook),
                              "Frequency/Time CW Doppler Radar Receiver")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook),
                              "FFT CW Doppler Radar Receiver Full Spectrum")
        self.GridAdd(self.notebook, 6, 0, 13, 53)
        _max_num_of_targets_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._max_num_of_targets_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_max_num_of_targets_tuner_sizer,
            value=self.max_num_of_targets_tuner,
            callback=self.set_max_num_of_targets_tuner,
            label="Maximum Number of Targets",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._max_num_of_targets_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_max_num_of_targets_tuner_sizer,
            value=self.max_num_of_targets_tuner,
            callback=self.set_max_num_of_targets_tuner,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.GridAdd(_max_num_of_targets_tuner_sizer, 2, 8, 1, 21)
        _lowpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._lowpass_cutoff_freq_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_lowpass_cutoff_freq_tuner_sizer,
            value=self.lowpass_cutoff_freq_tuner,
            callback=self.set_lowpass_cutoff_freq_tuner,
            label="Low-Pass Cutoff Frequency (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._lowpass_cutoff_freq_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_lowpass_cutoff_freq_tuner_sizer,
            value=self.lowpass_cutoff_freq_tuner,
            callback=self.set_lowpass_cutoff_freq_tuner,
            minimum=0,
            maximum=3000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_lowpass_cutoff_freq_tuner_sizer, 1, 29, 1, 24)
        _highpass_cutoff_freq_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._highpass_cutoff_freq_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_highpass_cutoff_freq_tuner_sizer,
            value=self.highpass_cutoff_freq_tuner,
            callback=self.set_highpass_cutoff_freq_tuner,
            label="High-Pass Cutoff Frequency (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._highpass_cutoff_freq_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_highpass_cutoff_freq_tuner_sizer,
            value=self.highpass_cutoff_freq_tuner,
            callback=self.set_highpass_cutoff_freq_tuner,
            minimum=0,
            maximum=1600,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_highpass_cutoff_freq_tuner_sizer, 0, 29, 1, 24)
        _doppler_signal_bw_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._doppler_signal_bw_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_doppler_signal_bw_tuner_sizer,
            value=self.doppler_signal_bw_tuner,
            callback=self.set_doppler_signal_bw_tuner,
            label="Doppler Spectrum Bandwidth (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._doppler_signal_bw_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_doppler_signal_bw_tuner_sizer,
            value=self.doppler_signal_bw_tuner,
            callback=self.set_doppler_signal_bw_tuner,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_doppler_signal_bw_tuner_sizer, 2, 29, 1, 24)
        self.direction_vector_probe = blocks.probe_signal_vi(
            max_num_of_targets)
        _angle_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._angle_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_angle_tuner_sizer,
            value=self.angle_tuner,
            callback=self.set_angle_tuner,
            label="Angle of Approach of the Target (Deg)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._angle_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_angle_tuner_sizer,
            value=self.angle_tuner,
            callback=self.set_angle_tuner,
            minimum=0,
            maximum=89,
            num_steps=890,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_angle_tuner_sizer, 1, 8, 1, 21)
        _RF_tuner_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RF_tuner_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_RF_tuner_sizer,
            value=self.RF_tuner,
            callback=self.set_RF_tuner,
            label="Radar Frequency (Hz)",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._RF_tuner_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_RF_tuner_sizer,
            value=self.RF_tuner,
            callback=self.set_RF_tuner,
            minimum=2.4e9,
            maximum=2.5e9,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_RF_tuner_sizer, 1, 0, 1, 8)
        self.wxgui_waterfallsink = waterfallsink2.waterfall_sink_c(
            self.notebook.GetPage(1).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate_sink,
            fft_size=1024,
            fft_rate=100,
            average=False,
            avg_alpha=None,
            title="Time/Frequency CW Doppler Radar Receiver",
            win=window.blackmanharris,
        )
        self.notebook.GetPage(1).Add(self.wxgui_waterfallsink.win)
        self.wxgui_fftsink2_full_spectrum = fftsink2.fft_sink_c(
            self.notebook.GetPage(2).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=4096,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT CW Doppler Radar Receiver Full Spectrum",
            peak_hold=False,
            win=window.blackmanharris,
        )
        self.notebook.GetPage(2).Add(self.wxgui_fftsink2_full_spectrum.win)
        self.wxgui_fftsink = fftsink2.fft_sink_c(
            self.notebook.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate_sink,
            fft_size=1024,
            fft_rate=100,
            average=False,
            avg_alpha=None,
            title="FFT CW Doppler Radar Receiver ",
            peak_hold=False,
            win=window.blackmanharris,
        )
        self.notebook.GetPage(0).Add(self.wxgui_fftsink.win)
        self.usrp_transmitter = uhd.usrp_sink(
            ",".join(('addr=192.168.10.2', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.usrp_transmitter.set_clock_source("internal", 0)
        self.usrp_transmitter.set_samp_rate(samp_rate)
        self.usrp_transmitter.set_center_freq(RF_tuner, 0)
        self.usrp_transmitter.set_gain(0, 0)
        self.usrp_transmitter.set_antenna("TX/RX", 0)
        self.usrp_receiver = uhd.usrp_source(
            ",".join(('addr=192.168.10.3', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.usrp_receiver.set_clock_source("mimo", 0)
        self.usrp_receiver.set_time_source("mimo", 0)
        self.usrp_receiver.set_samp_rate(samp_rate)
        self.usrp_receiver.set_center_freq(
            uhd.tune_request(RF_tuner, lo_offset_freq), 0)
        self.usrp_receiver.set_gain(rx_gain_tuner, 0)
        self.usrp_receiver.set_antenna("J1", 0)
        self.usrp_receiver.set_bandwidth(15e6, 0)

        def _target_speed_vector_probe():
            while True:
                val = self.speed_vector_probe.level()
                try:
                    self.set_target_speed_vector(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))

        _target_speed_vector_thread = threading.Thread(
            target=_target_speed_vector_probe)
        _target_speed_vector_thread.daemon = True
        _target_speed_vector_thread.start()

        def _target_direction_vector_probe():
            while True:
                val = self.direction_vector_probe.level()
                try:
                    self.set_target_direction_vector(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))

        _target_direction_vector_thread = threading.Thread(
            target=_target_direction_vector_probe)
        _target_direction_vector_thread.daemon = True
        _target_direction_vector_thread.start()
        self._speed_textbox_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.speed_textbox,
            callback=self.set_speed_textbox,
            label="Targets Speed (Kph)",
            converter=forms.str_converter(),
        )
        self.GridAdd(self._speed_textbox_text_box, 4, 0, 1, 53)
        self.rational_resampler = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=int(samp_rate / samp_rate_sink),
            taps=None,
            fractional_bw=None,
        )
        self._num_targets_textbox_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.num_targets_textbox,
            callback=self.set_num_targets_textbox,
            label="Number of Targets Detected",
            converter=forms.int_converter(),
        )
        self.GridAdd(self._num_targets_textbox_text_box, 3, 0, 1, 4)
        self.num_targets_probe = blocks.probe_signal_i()

        def _num_targets_probe():
            while True:
                val = self.num_targets_probe.level()
                try:
                    self.set_num_targets(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (speed_samp_rate))

        _num_targets_thread = threading.Thread(target=_num_targets_probe)
        _num_targets_thread.daemon = True
        _num_targets_thread.start()
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True,
                                     (window.blackmanharris(fft_len)), True, 1)
        self._direction_textbox_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.direction_textbox,
            callback=self.set_direction_textbox,
            label="Targets Direction",
            converter=forms.str_converter(),
        )
        self.GridAdd(self._direction_textbox_text_box, 5, 0, 1, 53)
        self.cwradar_vector_flip_ff = cwradar.vector_flip_ff(fft_len / 2)
        self.cwradar_doppler_velocity_multiple_targets_ff_0 = cwradar.doppler_velocity_multiple_targets_ff(
            fft_len / 2, samp_rate, RF_tuner, threshold_dB_tuner, angle_tuner,
            lowpass_cutoff_freq_tuner, highpass_cutoff_freq_tuner,
            max_num_of_targets_tuner, doppler_signal_bw_tuner)
        self.complex_to_mag = blocks.complex_to_mag(fft_len)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_len)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_len)
        self.blocks_stream_to_vector_1_0 = blocks.stream_to_vector(
            gr.sizeof_float * 1, fft_len / 2)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(
            gr.sizeof_float * 1, fft_len / 2)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_len)
        self.blocks_keep_m_in_n_0_0 = blocks.keep_m_in_n(
            gr.sizeof_float, fft_len / 2, fft_len, fft_len / 2)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_float,
                                                       fft_len / 2, fft_len, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 0, tx_amp_tuner, 0)
        self.DC_filter_0 = blocks.multiply_const_vff(
            ([0] * DC_filter_num_elements + [1] *
             ((fft_len / 2) - DC_filter_num_elements)))
        self.DC_filter = blocks.multiply_const_vff(
            ([0] * DC_filter_num_elements + [1] *
             ((fft_len / 2) - DC_filter_num_elements)))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.complex_to_mag, 0),
                     (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.complex_to_mag, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.DC_filter, 0),
                     (self.cwradar_doppler_velocity_multiple_targets_ff_0, 0))
        self.connect((self.DC_filter_0, 0),
                     (self.cwradar_doppler_velocity_multiple_targets_ff_0, 1))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff_0, 2),
                     (self.num_targets_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff_0, 1),
                     (self.direction_vector_probe, 0))
        self.connect((self.cwradar_doppler_velocity_multiple_targets_ff_0, 0),
                     (self.speed_vector_probe, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0),
                     (self.blocks_keep_m_in_n_0_0, 0))
        self.connect((self.blocks_keep_m_in_n_0, 0),
                     (self.blocks_stream_to_vector_1, 0))
        self.connect((self.blocks_keep_m_in_n_0_0, 0),
                     (self.blocks_stream_to_vector_1_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.blocks_stream_to_vector_1_0, 0),
                     (self.DC_filter_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0),
                     (self.cwradar_vector_flip_ff, 0))
        self.connect((self.cwradar_vector_flip_ff, 0), (self.DC_filter, 0))
        self.connect((self.usrp_receiver, 0),
                     (self.wxgui_fftsink2_full_spectrum, 0))
        self.connect((self.usrp_receiver, 0), (self.rational_resampler, 0))
        self.connect((self.rational_resampler, 0),
                     (self.wxgui_waterfallsink, 0))
        self.connect((self.rational_resampler, 0), (self.wxgui_fftsink, 0))
        self.connect((self.fft_vxx_0, 0), (self.complex_to_mag, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.usrp_receiver, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.usrp_transmitter, 0))
コード例 #19
0
def set_frame_icon(frame):
    if not is_mac():
        frame.SetIcon(wx.Icon(WIN_APP_ICON))
コード例 #20
0
    def __init__(self, parent, id=-1, title="", displayMethod=None, filterMethod=None, helpContext=None):
        """ Initialize the report framework.  Parameters are:
              parent               The report frame's parent
              id=-1                The report frame's ID
              title=""             The report title
              displayMethod=None   The method in the parent object that implements populating the report.
                                   (If left off, the report cannot function!)
              filterMethod=None    The method in the parent object that implements the Filter Dialog call.
                                   (If left off, no Filter option will be displayed.)
              helpContext=None     The Transana Help Context text for context-sensitive Help.
                                   (If left off, no Help option will be displayed.) """
        # It's always important to remember your ancestors.  (And the passed parameters!)
        self.parent = parent
        self.title = title
        # This instance of the TranscriptEditor object does NOT appear in a TranscriptionUI_RTC window
        # with Notebook Pages and Splitter Panes.  We give it an ActivePanel here so avoid problems
        # when the report is clicked on.
#        self.ActivePanel = 0
        self.reportNumber = 0
        self.helpContext = helpContext
        self.displayMethod = displayMethod
        self.filterMethod = filterMethod
        # Default the Control Object to None
        self.ControlObject = None
        # Determine the screen size for setting the initial dialog size
        rect = wx.Display(TransanaGlobal.configData.primaryScreen).GetClientArea()  # wx.ClientDisplayRect()
        width = rect[2] * .80
        height = rect[3] * .80
        # Create the basic Frame structure with a white background
        wx.Frame.__init__(self, parent, id, title, size=wx.Size(width, height), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL | wx.NO_FULL_REPAINT_ON_RESIZE)
        self.SetBackgroundColour(wx.WHITE)

        # Set the report's icon
        transanaIcon = wx.Icon(os.path.join(TransanaGlobal.programDir, "images", "Transana.ico"), wx.BITMAP_TYPE_ICO)
        self.SetIcon(transanaIcon)
        # You can't have a separate menu on the Mac, so we'll use a Toolbar
        self.toolBar = self.CreateToolBar(wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_TEXT)
        # If a Filter Method is defined ...
        if self.filterMethod != None:
            # ... and create a Filter button on the tool bar.
            self.toolBar.AddTool(T_FILE_FILTER, TransanaImages.ArtProv_LISTVIEW.GetBitmap(), shortHelpString=_("Filter"))
        # Add an Edit button  to the Toolbar
        self.toolBar.AddTool(T_FILE_EDIT, TransanaImages.ReadOnly16.GetBitmap(), isToggle=True, shortHelpString=_('Edit/Read-only select'))
        # ... and create a Format button on the tool bar.
        self.toolBar.AddTool(T_FILE_FONT, TransanaImages.ArtProv_HELPSETTINGS.GetBitmap(), shortHelpString=_("Format"))
        # Disable the Font button
        self.toolBar.EnableTool(T_FILE_FONT, False)
        # Add a Save button to the Toolbar
        self.toolBar.AddTool(T_FILE_SAVEAS, TransanaImages.Save16.GetBitmap(), shortHelpString=_('Save As'))
        # Disable Save for Right-To-Left languages
        if (TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft):
            self.toolBar.EnableTool(T_FILE_SAVEAS, False)

        # Add a Print (page) Setup button to the toolbar
        self.toolBar.AddTool(T_FILE_PRINTSETUP, TransanaImages.PrintSetup.GetBitmap(), shortHelpString=_('Set up Page'))
        # Disable Print Setup for Right-To-Left languages
        if (TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft):
            self.toolBar.EnableTool(T_FILE_PRINTSETUP, False)

        # Add a Print Preview button to the Toolbar
        self.toolBar.AddTool(T_FILE_PRINTPREVIEW, TransanaImages.PrintPreview.GetBitmap(), shortHelpString=_('Print Preview'))
        # Disable Print Preview on the PPC Mac and for Right-To-Left languages
        if (platform.processor() == 'powerpc') or (TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft):
            self.toolBar.EnableTool(T_FILE_PRINTPREVIEW, False)

        # Add a Print button to the Toolbar
        self.toolBar.AddTool(T_FILE_PRINT, TransanaImages.Print.GetBitmap(), shortHelpString=_('Print'))
        # Disable Print Setup for Right-To-Left languages
        if (TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft):
            self.toolBar.EnableTool(T_FILE_PRINT, False)

        # If a help context is defined ...
        if self.helpContext != None:
            # ... and create a bitmap button for the Help button
            self.toolBar.AddTool(T_HELP_HELP, TransanaImages.ArtProv_HELP.GetBitmap(), shortHelpString=_("Help"))
        # Add an Exit button to the Toolbar
        self.toolBar.AddTool(T_FILE_EXIT, TransanaImages.Exit.GetBitmap(), shortHelpString=_('Exit'))
        # Add a toolbar separator
        self.toolBar.AddSeparator()
        # Add the Search Backwards button
        self.toolBar.AddTool(T_SEARCH_BACK, TransanaImages.ArtProv_BACK.GetBitmap(), shortHelpString=_('Search backwards'))
        # Create a text box for search terms, with the toolbar as its parent.
        self.searchText = wx.TextCtrl(self.toolBar, -1, size=(100, 20), style=wx.TE_PROCESS_ENTER)
        # Add the text box to the toolbar.
        self.toolBar.AddControl(self.searchText)
        # Add the Search Forwards button
        self.toolBar.AddTool(T_SEARCH_FORWARD, TransanaImages.ArtProv_FORWARD.GetBitmap(), shortHelpString=_('Search forwards'))
        # Actually create the Toolbar
        self.toolBar.Realize()
        # Let's go ahead and keep the menu for non-Mac platforms
        if not '__WXMAC__' in wx.PlatformInfo:
            # Add a Menu Bar
            menuBar = wx.MenuBar()
            # Create the File Menu
            self.menuFile = wx.Menu()
            # If a Filter Method is defined ...
            if self.filterMethod != None:
                # ... add a Filter item to the File menu
                self.menuFile.Append(M_FILE_FILTER, _("&Filter"), _("Filter report contents"))
            # Add "Edit" to the File Menu
            self.menuFile.Append(M_FILE_EDIT, _("&Edit"), _("Edit the report manually"))
            # Add "Font" to the File Menu
            self.menuFile.Append(M_FILE_FONT, _("Format"), _("Change the current formatting"))
            # Disable the Font Menu Option
            self.menuFile.Enable(M_FILE_FONT, False)
            # Add "Save As" to File Menu
            self.menuFile.Append(M_FILE_SAVEAS, _("Save &As"), _("Save As"))
            # If we have Right to Left text, we cannot enable PRINT because it doesn't work right due to wxWidgets bugs.
            if TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft:
                self.menuFile.Enable(M_FILE_SAVEAS, False)
                
            # Add "Page Setup" to the File Menu
            self.menuFile.Append(M_FILE_PRINTSETUP, _("Page Setup"), _("Set up Page"))
            # If we have Right to Left text, we cannot enable PRINT because it doesn't work right due to wxWidgets bugs.
            if TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft:
                self.menuFile.Enable(M_FILE_PRINTSETUP, False)
                
            # Add "Print Preview" to the File Menu
            self.menuFile.Append(M_FILE_PRINTPREVIEW, _("Print Preview"), _("Preview your printed output"))
            # If we have Right to Left text, we cannot enable PRINT because it doesn't work right due to wxWidgets bugs.
            if TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft:
                self.menuFile.Enable(M_FILE_PRINTPREVIEW, False)
            
            # Add "Print" to the File Menu
            self.menuFile.Append(M_FILE_PRINT, _("&Print"), _("Send your output to the Printer"))
            # If we have Right to Left text, we cannot enable PRINT because it doesn't work right due to wxWidgets bugs.
            if TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft:
                self.menuFile.Enable(M_FILE_PRINT, False)
                
            # Add "Exit" to the File Menu
            self.menuFile.Append(M_FILE_EXIT, _("E&xit"), _("Exit the Keyword Map program"))
            # Add the File Menu to the Menu Bar
            menuBar.Append(self.menuFile, _('&File'))

            # If a Help Context is defined ...
            if self.helpContext != None:
                # ... create a Help menu ...
                self.menuHelp = wx.Menu()
                # ... add a Help item to the Help menu ...
                self.menuHelp.Append(M_HELP_HELP, _("&Help"), _("Help"))
                # ... and add the Help menu to the menu bar
                menuBar.Append(self.menuHelp, _("&Help"))
            # Connect the Menu Bar to the Frame
            self.SetMenuBar(menuBar)
        # Link menu items and toolbar buttons to the appropriate methods
        if self.filterMethod != None:
            wx.EVT_MENU(self, M_FILE_FILTER, self.OnFilter)                           # Attach File > Filter to a method
            wx.EVT_MENU(self, T_FILE_FILTER, self.OnFilter)                           # Attach Toolbar Filter to a method
        wx.EVT_MENU(self, M_FILE_EDIT, self.OnEdit)                                   # Attach OnEdit to File > Edit
        wx.EVT_MENU(self, T_FILE_EDIT, self.OnEdit)                                   # Attach OnEdit to Toolbar Edit
        wx.EVT_MENU(self, M_FILE_FONT, self.OnFont)                                   # Attach OnFont to File > Font
        wx.EVT_MENU(self, T_FILE_FONT, self.OnFont)                                   # Attach OnFont to Toolbar Font button
        wx.EVT_MENU(self, M_FILE_SAVEAS, self.OnSaveAs)                               # Attach File > Save As to a method
        wx.EVT_MENU(self, T_FILE_SAVEAS, self.OnSaveAs)                               # Attach Toolbar Save As to a method
        wx.EVT_MENU(self, M_FILE_PRINTSETUP, self.OnPrintSetup)                       # Attach File > Print Setup to a method
        wx.EVT_MENU(self, T_FILE_PRINTSETUP, self.OnPrintSetup)                       # Attach Toolbar Print Setup to a method
        wx.EVT_MENU(self, M_FILE_PRINTPREVIEW, self.OnPrintPreview)                   # Attach File > Print Preview to a method
        wx.EVT_MENU(self, T_FILE_PRINTPREVIEW, self.OnPrintPreview)                   # Attach Toolbar Print Preview to a method
        wx.EVT_MENU(self, M_FILE_PRINT, self.OnPrint)                                 # Attach File > Print to a method
        wx.EVT_MENU(self, T_FILE_PRINT, self.OnPrint)                                 # Attach Toolbar Print to a method
        wx.EVT_MENU(self, M_FILE_EXIT, self.CloseWindow)                              # Attach CloseWindow to File > Exit
        wx.EVT_MENU(self, T_FILE_EXIT, self.CloseWindow)                              # Attach CloseWindow to Toolbar Exit
        wx.EVT_MENU(self, T_SEARCH_BACK, self.OnSearch)                               # Attach Toolbar Search Backwards to Search method
        wx.EVT_MENU(self, T_SEARCH_FORWARD, self.OnSearch)                            # Attach Toolbar Search Forwards to Search method
        self.searchText.Bind(wx.EVT_TEXT_ENTER, self.OnSearch)                        # Attach Search Box Enter event to Search method
        if self.helpContext != None:
            wx.EVT_MENU(self, M_HELP_HELP, self.OnHelp)                               # Attach OnHelp to Help > Help
            wx.EVT_MENU(self, T_HELP_HELP, self.OnHelp)                               # Attach OnHelp to Toolbar Help
        # Define the Window's Close event, so we can remove the window from the Transana Interface
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        # Add a Status Bar
        self.CreateStatusBar()

        # Create a Sizer
        s1 = wx.BoxSizer(wx.HORIZONTAL)

        # If we're using the RTC 
        if TransanaConstants.USESRTC:
            # Add a Rich Text Edit control to the Report Frame.  This is where the actual report text goes.
            self.reportText = TranscriptEditor_RTC.TranscriptEditor(self)
            # Add the Rich Text Edit Control to the Sizer
            s1.Add(self.reportText, 1, wx.EXPAND)
            
            # Clear / initialize the document
            self.reportText.ClearDoc()
##        # If we're using STC
##        else:
##            # Add a Styled Text Edit control to the Report Frame.  This is where the actual report text goes.
##            self.reportText = TranscriptEditor_STC.TranscriptEditor(self)
##            # Set report margins, the left margin to 1 inch, the right margin to 0 to prevent premature word wrap.
##            self.reportText.SetMargins(TranscriptPrintoutClass.DPI, 0)
        # We need to over-ride the reportText's EVT_RIGHT_UP method
        wx.EVT_RIGHT_UP(self.reportText, self.OnRightUp)
        # Initialize a variable to indicate whether a custom edit has occurred
        self.reportEdited = False
        # Get the global print data
        self.printData = TransanaGlobal.printData

        # If the report has no Parent ...
        if parent == None:
            # ... center it on the screen
            TransanaGlobal.CenterOnPrimary(self)

        # Define the Page's main sizer
        self.SetSizer(s1)
        # Lay out the page
        self.Layout()
        self.SetAutoLayout(True)

        # Show the Frame
        self.Show(True)
コード例 #21
0
ファイル: rx_example.py プロジェクト: cbodes/radio
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Radio")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.volume = volume = 1
        self.sample_rate = sample_rate = 5e6
        self.freq = freq = 105.1e6
        self.fm_sample = fm_sample = 500e3
        self.audio_rate = audio_rate = 48e3

        ##################################################
        # Blocks
        ##################################################
        _volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._volume_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            label="Volume",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._volume_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            minimum=0,
            maximum=10,
            num_steps=20,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_volume_sizer)
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_sizer,
            value=self.freq,
            callback=self.set_freq,
            label="Frequency",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_sizer,
            value=self.freq,
            callback=self.set_freq,
            minimum=80e6,
            maximum=180e6,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_freq_sizer)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=freq,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=sample_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=int(audio_rate/1000),
            decimation=int(fm_sample/10000),
            taps=None,
            fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "hackrf=0000000000000000325866e6299d8023")
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(int(sample_rate / fm_sample), firdes.low_pass(
            1, sample_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.audio_sink_0 = audio.sink(int(audio_rate), "", True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=fm_sample,
            audio_decimation=10,
        )
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, volume)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0))
コード例 #22
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.ntaps = ntaps = 11 * nfilts * sps
        self.excess_bw = excess_bw = 400e-3
        self.tx_taps = tx_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, excess_bw, ntaps)
        self.timing_bw = timing_bw = 2 * pi / 100
        self.tap4 = tap4 = 0.0625
        self.tap3 = tap3 = -0.125
        self.tap2 = tap2 = 0.25
        self.tap1 = tap1 = -0.5
        self.sqrt_2 = sqrt_2 = 1.41421356237
        self.samp_rate = samp_rate = 32000
        self.rx_taps = rx_taps = filter.firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, excess_bw, ntaps)
        self.const_points = const_points = 8

        ##################################################
        # Blocks
        ##################################################
        _tap4_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tap4_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_tap4_sizer,
            value=self.tap4,
            callback=self.set_tap4,
            label='tap4',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._tap4_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_tap4_sizer,
            value=self.tap4,
            callback=self.set_tap4,
            minimum=-1,
            maximum=1,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_tap4_sizer)
        _tap3_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tap3_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_tap3_sizer,
            value=self.tap3,
            callback=self.set_tap3,
            label='tap3',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._tap3_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_tap3_sizer,
            value=self.tap3,
            callback=self.set_tap3,
            minimum=-1,
            maximum=1,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_tap3_sizer)
        _tap2_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tap2_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_tap2_sizer,
            value=self.tap2,
            callback=self.set_tap2,
            label='tap2',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._tap2_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_tap2_sizer,
            value=self.tap2,
            callback=self.set_tap2,
            minimum=-1,
            maximum=1,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_tap2_sizer)
        _tap1_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tap1_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_tap1_sizer,
            value=self.tap1,
            callback=self.set_tap1,
            label='tap1',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._tap1_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_tap1_sizer,
            value=self.tap1,
            callback=self.set_tap1,
            minimum=-1,
            maximum=1,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_tap1_sizer)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab1")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab2")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab3")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab4")
        self.Add(self.notebook_0)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.notebook_0.GetPage(0).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_scopesink2_0.win)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(sps,
                                                             taps=(tx_taps),
                                                             flt_size=32)

        self.iir_filter_ffd_0_0 = filter.iir_filter_ffd(
            ([1, tap1, tap2, tap3, tap4]), ([1]), True)
        self.iir_filter_ffd_0 = filter.iir_filter_ffd(
            ([1, tap1, tap2, tap3, tap4]), ([1]), True)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_bw, (rx_taps), 32, 16, 1.5, 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (((1), (0.707 + 0.707j), (1j), (-0.707 + 0.707j), (-1),
              (-0.707 - 0.707j), (-1j), (0.707 - 0.707j))), 1)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate * sps)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.5, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, const_points, 1000)), True)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 0.07, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.iir_filter_ffd_0_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.iir_filter_ffd_0, 0))
        self.connect((self.iir_filter_ffd_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.iir_filter_ffd_0_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 2))
コード例 #23
0
ファイル: IRIDA.py プロジェクト: YautongNg/gengis
	def __init__(self,Parent = None):
		IRIDAClientLayout.__init__(self,Parent)
		self.parent = Parent
		self.SetIcon(wx.Icon(GenGIS.mainWindow.GetExeDir() + "images/CrazyEye.ico",wx.BITMAP_TYPE_ICO))
		self.index=-1
コード例 #24
0
ファイル: Dial_Tone.py プロジェクト: pywill/SDR-1
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Dial Tone")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.src_freq_1 = src_freq_1 = 350
        self.samp_rate = samp_rate = 32000
        self.noise_amp = noise_amp = .005
        self.Src_freq_2 = Src_freq_2 = 440

        ##################################################
        # Blocks
        ##################################################
        _src_freq_1_sizer = wx.BoxSizer(wx.VERTICAL)
        self._src_freq_1_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_src_freq_1_sizer,
            value=self.src_freq_1,
            callback=self.set_src_freq_1,
            label="Src_Freq_1",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._src_freq_1_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_src_freq_1_sizer,
            value=self.src_freq_1,
            callback=self.set_src_freq_1,
            minimum=0,
            maximum=1000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_src_freq_1_sizer)
        _noise_amp_sizer = wx.BoxSizer(wx.VERTICAL)
        self._noise_amp_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_noise_amp_sizer,
            value=self.noise_amp,
            callback=self.set_noise_amp,
            label="noise_amp",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._noise_amp_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_noise_amp_sizer,
            value=self.noise_amp,
            callback=self.set_noise_amp,
            minimum=0,
            maximum=0.1,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_noise_amp_sizer)
        _Src_freq_2_sizer = wx.BoxSizer(wx.VERTICAL)
        self._Src_freq_2_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_Src_freq_2_sizer,
            value=self.Src_freq_2,
            callback=self.set_Src_freq_2,
            label="Src_Freq_2",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._Src_freq_2_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_Src_freq_2_sizer,
            value=self.Src_freq_2,
            callback=self.set_Src_freq_2,
            minimum=0,
            maximum=1000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_Src_freq_2_sizer)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_sig_source_x_1 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, Src_freq_2, 0.1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, src_freq_1, .1, 0)
        self.analog_noise_source_x_0 = analog.noise_source_f(
            analog.GR_GAUSSIAN, noise_amp, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_add_xx_0, 0), (self.wxgui_scopesink2_0, 0))
コード例 #25
0
ファイル: LeoSpy.py プロジェクト: Ravi-Panga/LeoSpy
 def __init__(self, parent):
     lsu.MyFrame1.__init__(self, parent)
     self.PhotoMaxSize = 600  # a self
     icon = wx.Icon('logo.png', wx.BITMAP_TYPE_ANY)
     self.SetIcon(icon)
コード例 #26
0
    def __init__(self, parent, id, title, size):
        wx.Frame.__init__(
            self,
            parent,
            id,
            title,
            style=wx.DEFAULT_FRAME_STYLE ^
            (wx.RESIZE_BORDER | wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX))

        # 设置背景图片
        background_image = './fig/background.jpg'
        to_bmp_image = wx.Image(background_image,
                                wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.background_bitmap = wx.StaticBitmap(self, -1, to_bmp_image,
                                                 (0, 0))

        # 设置选框
        self.choose_relation = wx.Choice(self.background_bitmap,
                                         choices=relation_list,
                                         pos=(299, 450),
                                         size=(100, 25))
        self.choose_character = wx.Choice(self.background_bitmap,
                                          choices=character_list,
                                          pos=(164, 489),
                                          size=(100, 25))
        self.choose_sex = wx.Choice(self.background_bitmap,
                                    choices=sex_list,
                                    pos=(164, 450),
                                    size=(100, 25))
        self.choose_character.Bind(wx.EVT_CHOICE, self.change_Hint)
        self.choose_relation.Bind(wx.EVT_CHOICE, self.change_Hint)
        self.choose_sex.Bind(wx.EVT_CHOICE, self.change_Hint)

        #设置按键
        self.showRuleButton = wx.Button(self.background_bitmap,
                                        label='查看规则~',
                                        pos=(747, 450),
                                        size=(100, 25))
        self.OKButton = wx.Button(self.background_bitmap,
                                  label='寻找礼物~',
                                  pos=(747, 489),
                                  size=(100, 25))
        self.EditButton = wx.Button(self.background_bitmap,
                                    label='添加规则~',
                                    pos=(747, 528),
                                    size=(100, 25))
        #设置控件关联函数
        self.showRuleButton.Bind(wx.EVT_BUTTON, self.showRules)
        self.OKButton.Bind(wx.EVT_BUTTON, self.getResults)
        self.EditButton.Bind(wx.EVT_BUTTON, self.EditRules)

        #设置图标
        icon = wx.Icon()
        icon.LoadFile("./fig/Icon.ico", wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)

        #设置静态文本
        self.HintLabel = wx.StaticText(self.background_bitmap,
                                       1,
                                       label='请选择~',
                                       pos=(445, 470))
        self.HintLabel.SetBackgroundColour('white')

        #self.show_picture('../fig/wet.png', pic1_pos)

        #设置基本参数
        self.SetSize(size)
        self.Center()
        self.title = title
        self.pic_path = None
        self.engine = None
        self.contour_num = None
        self.Show()
コード例 #27
0
    def __init__(self, parent, log):

        wx.Panel.__init__(self,
                          parent,
                          style=wx.TAB_TRAVERSAL
                          | wx.NO_FULL_REPAINT_ON_RESIZE)

        panel = wx.Panel(self, -1)
        sizer = wx.FlexGridSizer(2, 3, 2, 5)

        # 6 Panels To Hold The SpeedMeters ;-)

        panel1 = wx.Panel(panel, -1, style=wx.SUNKEN_BORDER)
        panel2 = wx.Panel(panel, -1, style=wx.RAISED_BORDER)
        panel3 = wx.Panel(panel, -1, style=wx.SUNKEN_BORDER)
        panel4 = wx.Panel(panel, -1, style=wx.RAISED_BORDER)
        panel5 = wx.Panel(panel, -1, style=wx.SUNKEN_BORDER)
        panel6 = wx.Panel(panel, -1, style=wx.RAISED_BORDER)

        # First SpeedMeter: We Use The Following Styles:
        #
        # SM_DRAW_HAND: We Want To Draw The Hand (Arrow) Indicator
        # SM_DRAW_SECTORS: Full Sectors Will Be Drawn, To Indicate Different Intervals
        # SM_DRAW_MIDDLE_TEXT: We Draw Some Text In The Center Of SpeedMeter
        # SM_DRAW_SECONDARY_TICKS: We Draw Secondary (Intermediate) Ticks Between
        #                          The Main Ticks (Intervals)

        self.SpeedWindow1 = SM.SpeedMeter(
            panel1,
            agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_SECTORS
            | SM.SM_DRAW_MIDDLE_TEXT | SM.SM_DRAW_SECONDARY_TICKS)

        # Set The Region Of Existence Of SpeedMeter (Always In Radians!!!!)
        self.SpeedWindow1.SetAngleRange(-pi / 6, 7 * pi / 6)

        # Create The Intervals That Will Divide Our SpeedMeter In Sectors
        intervals = range(0, 201, 20)
        self.SpeedWindow1.SetIntervals(intervals)

        # Assign The Same Colours To All Sectors (We Simulate A Car Control For Speed)
        # Usually This Is Black
        colours = [wx.BLACK] * 10
        self.SpeedWindow1.SetIntervalColours(colours)

        # Assign The Ticks: Here They Are Simply The String Equivalent Of The Intervals
        ticks = [str(interval) for interval in intervals]
        self.SpeedWindow1.SetTicks(ticks)
        # Set The Ticks/Tick Markers Colour
        self.SpeedWindow1.SetTicksColour(wx.WHITE)
        # We Want To Draw 5 Secondary Ticks Between The Principal Ticks
        self.SpeedWindow1.SetNumberOfSecondaryTicks(5)

        # Set The Font For The Ticks Markers
        self.SpeedWindow1.SetTicksFont(
            wx.Font(7, wx.SWISS, wx.NORMAL, wx.NORMAL))

        # Set The Text In The Center Of SpeedMeter
        self.SpeedWindow1.SetMiddleText("Km/h")
        # Assign The Colour To The Center Text
        self.SpeedWindow1.SetMiddleTextColour(wx.WHITE)
        # Assign A Font To The Center Text
        self.SpeedWindow1.SetMiddleTextFont(
            wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD))

        # Set The Colour For The Hand Indicator
        self.SpeedWindow1.SetHandColour(wx.Colour(255, 50, 0))

        # Do Not Draw The External (Container) Arc. Drawing The External Arc May
        # Sometimes Create Uglier Controls. Try To Comment This Line And See It
        # For Yourself!
        self.SpeedWindow1.DrawExternalArc(False)

        # Set The Current Value For The SpeedMeter
        self.SpeedWindow1.SetSpeedValue(44)

        # Second SpeedMeter: We Use The Following Styles:
        #
        # SM_DRAW_HAND: We Want To Draw The Hand (Arrow) Indicator
        # SM_DRAW_SECTORS: Full Sectors Will Be Drawn, To Indicate Different Intervals
        # SM_DRAW_MIDDLE_TEXT: We Draw Some Text In The Center Of SpeedMeter
        # SM_DRAW_SECONDARY_TICKS: We Draw Secondary (Intermediate) Ticks Between
        #                          The Main Ticks (Intervals)
        # SM_DRAW_PARTIAL_FILLER: The Region Passed By The Hand Indicator Is Highlighted
        #                         With A Different Filling Colour
        # SM_DRAW_SHADOW: A Shadow For The Hand Indicator Is Drawn

        self.SpeedWindow2 = SM.SpeedMeter(
            panel2,
            agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_SECTORS
            | SM.SM_DRAW_MIDDLE_TEXT | SM.SM_DRAW_SECONDARY_TICKS
            | SM.SM_DRAW_PARTIAL_FILLER | SM.SM_DRAW_SHADOW)

        # We Want To Simulate A Clock. Somewhat Tricky, But Did The Job
        self.SpeedWindow2.SetAngleRange(pi / 2, 5 * pi / 2)

        intervals = range(0, 13)
        self.SpeedWindow2.SetIntervals(intervals)

        colours = [wx.SystemSettings_GetColour(0)] * 12
        self.SpeedWindow2.SetIntervalColours(colours)

        ticks = [str(interval) for interval in intervals]
        ticks[-1] = ""
        ticks[0] = "12"
        self.SpeedWindow2.SetTicks(ticks)
        self.SpeedWindow2.SetTicksColour(wx.BLUE)
        self.SpeedWindow2.SetTicksFont(
            wx.Font(11, wx.SCRIPT, wx.NORMAL, wx.BOLD, True))
        self.SpeedWindow2.SetNumberOfSecondaryTicks(4)

        # Set The Colour For The External Arc
        self.SpeedWindow2.SetArcColour(wx.BLUE)

        self.SpeedWindow2.SetHandColour(wx.BLACK)

        self.SpeedWindow2.SetMiddleText("0 s")
        self.SpeedWindow2.SetMiddleTextColour(wx.RED)

        # We Set The Background Colour Of The SpeedMeter OutSide The Control
        self.SpeedWindow2.SetSpeedBackground(wx.WHITE)

        # Set The Colour For The Shadow
        self.SpeedWindow2.SetShadowColour(wx.Colour(128, 128, 128))

        self.SpeedWindow2.SetSpeedValue(0.0)

        # Third SpeedMeter: We Use The Following Styles:
        #
        # SM_DRAW_HAND: We Want To Draw The Hand (Arrow) Indicator
        # SM_DRAW_PARTIAL_SECTORS: Partial Sectors Will Be Drawn, To Indicate Different Intervals
        # SM_DRAW_MIDDLE_ICON: We Draw An Icon In The Center Of SpeedMeter

        self.SpeedWindow3 = SM.SpeedMeter(panel3,
                                          agwStyle=SM.SM_DRAW_HAND
                                          | SM.SM_DRAW_PARTIAL_SECTORS
                                          | SM.SM_DRAW_MIDDLE_ICON)

        # We Want To Simulate A Car Gas-Control
        self.SpeedWindow3.SetAngleRange(-pi / 3, pi / 3)

        intervals = range(0, 5)
        self.SpeedWindow3.SetIntervals(intervals)

        colours = [wx.BLACK] * 3
        colours.append(wx.RED)
        self.SpeedWindow3.SetIntervalColours(colours)

        ticks = ["F", "", "", "", "E"]
        self.SpeedWindow3.SetTicks(ticks)
        self.SpeedWindow3.SetTicksColour(wx.WHITE)

        self.SpeedWindow3.SetHandColour(wx.Colour(255, 255, 0))

        # Define The Icon We Want
        icon = wx.Icon(os.path.normpath(os.path.join(bitmapDir, "smfuel.ico")),
                       wx.BITMAP_TYPE_ICO)
        icon.SetWidth(24)
        icon.SetHeight(24)

        # Draw The Icon In The Center Of SpeedMeter
        self.SpeedWindow3.SetMiddleIcon(icon)

        self.SpeedWindow3.SetSpeedBackground(wx.BLACK)

        self.SpeedWindow3.SetArcColour(wx.WHITE)

        self.SpeedWindow3.SetSpeedValue(0.7)

        # Fourth SpeedMeter: We Use The Following Styles:
        #
        # SM_DRAW_HAND: We Want To Draw The Hand (Arrow) Indicator
        # SM_DRAW_SECTORS: Full Sectors Will Be Drawn, To Indicate Different Intervals
        # SM_DRAW_SHADOW: A Shadow For The Hand Indicator Is Drawn
        # SM_DRAW_MIDDLE_ICON: We Draw An Icon In The Center Of SpeedMeter
        #
        # NOTE: We Use The Mouse Style mousestyle=SM_MOUSE_TRACK. In This Way, Mouse
        # Events Are Catched (Mainly Left Clicks/Drags) And You Can Change The Speed
        # Value Using The Mouse

        self.SpeedWindow4 = SM.SpeedMeter(
            panel4,
            agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_SECTORS | SM.SM_DRAW_SHADOW
            | SM.SM_DRAW_MIDDLE_ICON,
            mousestyle=SM.SM_MOUSE_TRACK)

        # We Want To Simulate Some Kind Of Thermometer (In Celsius Degrees!!!)
        self.SpeedWindow4.SetAngleRange(pi, 2 * pi)

        intervals = range(35, 44)
        self.SpeedWindow4.SetIntervals(intervals)

        colours = [wx.BLUE] * 5
        colours.extend([wx.Colour(255, 255, 0)] * 2)
        colours.append(wx.RED)
        self.SpeedWindow4.SetIntervalColours(colours)

        ticks = [str(interval) + "C" for interval in intervals]
        self.SpeedWindow4.SetTicks(ticks)
        self.SpeedWindow4.SetTicksColour(wx.BLACK)
        self.SpeedWindow4.SetTicksFont(
            wx.Font(7, wx.TELETYPE, wx.NORMAL, wx.BOLD))

        self.SpeedWindow4.SetHandColour(wx.Colour(0, 0, 255))

        self.SpeedWindow4.SetSpeedBackground(wx.SystemSettings_GetColour(0))

        self.SpeedWindow4.DrawExternalArc(False)

        self.SpeedWindow4.SetHandColour(wx.GREEN)
        self.SpeedWindow4.SetShadowColour(wx.Colour(50, 50, 50))

        # We Want A Simple Arrow As Indicator, Not The More Scenic Hand ;-)
        self.SpeedWindow4.SetHandStyle("Arrow")

        # Define The Icon We Want
        icon = wx.Icon(os.path.normpath(os.path.join(bitmapDir, "smtemp.ico")),
                       wx.BITMAP_TYPE_ICO)
        icon.SetWidth(16)
        icon.SetHeight(16)

        # Draw The Icon In The Center Of SpeedMeter
        self.SpeedWindow4.SetMiddleIcon(icon)

        # Quite An High Fever!!!
        self.SpeedWindow4.SetSpeedValue(41.4)

        # Fifth SpeedMeter: We Use The Following Styles:
        #
        # SM_DRAW_HAND: We Want To Draw The Hand (Arrow) Indicator
        # SM_DRAW_PARTIAL_SECTORS: Partial Sectors Will Be Drawn, To Indicate Different Intervals
        # SM_DRAW_SECONDARY_TICKS: We Draw Secondary (Intermediate) Ticks Between
        #                          The Main Ticks (Intervals)
        # SM_DRAW_MIDDLE_TEXT: We Draw Some Text In The Center Of SpeedMeter
        # SM_ROTATE_TEXT: The Ticks Texts Are Rotated Accordingly To Their Angle

        self.SpeedWindow5 = SM.SpeedMeter(
            panel5,
            agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_PARTIAL_SECTORS
            | SM.SM_DRAW_SECONDARY_TICKS | SM.SM_DRAW_MIDDLE_TEXT
            | SM.SM_ROTATE_TEXT)

        # We Want To Simulate The Round Per Meter Control In A Car
        self.SpeedWindow5.SetAngleRange(-pi / 6, 7 * pi / 6)

        intervals = range(0, 9)
        self.SpeedWindow5.SetIntervals(intervals)

        colours = [wx.BLACK] * 6
        colours.append(wx.Colour(255, 255, 0))
        colours.append(wx.RED)
        self.SpeedWindow5.SetIntervalColours(colours)

        ticks = [str(interval) for interval in intervals]
        self.SpeedWindow5.SetTicks(ticks)
        self.SpeedWindow5.SetTicksColour(wx.WHITE)
        self.SpeedWindow5.SetTicksFont(
            wx.Font(7, wx.SWISS, wx.NORMAL, wx.NORMAL))

        self.SpeedWindow5.SetHandColour(wx.Colour(255, 50, 0))

        self.SpeedWindow5.SetSpeedBackground(wx.SystemSettings_GetColour(0))

        self.SpeedWindow5.DrawExternalArc(False)

        self.SpeedWindow5.SetShadowColour(wx.Colour(50, 50, 50))

        self.SpeedWindow5.SetMiddleText("rpm")
        self.SpeedWindow5.SetMiddleTextColour(wx.WHITE)
        self.SpeedWindow5.SetMiddleTextFont(
            wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD))
        self.SpeedWindow5.SetSpeedBackground(wx.Colour(160, 160, 160))

        self.SpeedWindow5.SetSpeedValue(5.6)

        # Sixth SpeedMeter: That Is Complete And Complex Example.
        #                   We Use The Following Styles:
        #
        # SM_DRAW_HAND: We Want To Draw The Hand (Arrow) Indicator
        # SM_DRAW_PARTIAL_FILLER: The Region Passed By The Hand Indicator Is Highlighted
        #                         With A Different Filling Colour
        # SM_DRAW_MIDDLE_ICON: We Draw An Icon In The Center Of SpeedMeter
        # SM_DRAW_GRADIENT: A Circular Colour Gradient Is Drawn Inside The SpeedMeter, To
        #                   Give Some Kind Of Scenic Effect
        # SM_DRAW_FANCY_TICKS: We Use wx.lib.
        # SM_DRAW_SHADOW: A Shadow For The Hand Indicator Is Drawn

        self.SpeedWindow6 = SM.SpeedMeter(
            panel6,
            agwStyle=SM.SM_DRAW_HAND | SM.SM_DRAW_PARTIAL_FILLER
            | SM.SM_DRAW_MIDDLE_ICON | SM.SM_DRAW_GRADIENT
            | SM.SM_DRAW_FANCY_TICKS | SM.SM_DRAW_SHADOW)

        self.SpeedWindow6.SetAngleRange(0, 4 * pi / 3)

        intervals = [
            0, pi / 6,
            sqrt(pi), 2. / 3. * pi, pi**2 / 4, pi, 7. / 6. * pi, 4 * pi / 3
        ]
        self.SpeedWindow6.SetIntervals(intervals)

        # If You Use The Style SM_DRAW_FANCY_TICKS, Refer To wx.lib.fancytext To Create
        # Correct XML Strings To Put Here
        ticks = [
            "0", "<pi/>/6", "sq(<pi/>)", "2<pi/>/3", "<pi/><sup>2</sup>/4",
            "<pi/>", "7<pi/>/6", "4<pi/>/3"
        ]
        self.SpeedWindow6.SetTicks(ticks)
        self.SpeedWindow6.SetTicksColour(wx.Colour(0, 90, 0))
        self.SpeedWindow6.SetTicksFont(wx.Font(6, wx.ROMAN, wx.NORMAL,
                                               wx.BOLD))

        self.SpeedWindow6.SetHandColour(wx.Colour(60, 60, 60))

        self.SpeedWindow6.DrawExternalArc(False)

        self.SpeedWindow6.SetFillerColour(wx.Colour(145, 220, 200))

        self.SpeedWindow6.SetShadowColour(wx.BLACK)

        self.SpeedWindow6.SetDirection("Reverse")

        self.SpeedWindow6.SetSpeedBackground(wx.SystemSettings_GetColour(0))

        # Set The First Gradient Colour, Which Is The Colour Near The External Arc
        self.SpeedWindow6.SetFirstGradientColour(wx.RED)
        # Set The Second Gradient Colour, Which Is The Colour Near The Center Of The SpeedMeter
        self.SpeedWindow6.SetSecondGradientColour(wx.WHITE)

        icon = wx.Icon(os.path.normpath(os.path.join(bitmapDir, "smpi.ico")),
                       wx.BITMAP_TYPE_ICO)
        icon.SetHeight(12)
        icon.SetWidth(12)
        self.SpeedWindow6.SetMiddleIcon(icon)

        self.SpeedWindow6.SetSpeedValue(pi / 3)

        # End Of SpeedMeter Controls Construction. Add Some Functionality

        self.isalive = 0

        # These Are Cosmetics For The First SpeedMeter Control
        bsizer1 = wx.BoxSizer(wx.VERTICAL)

        hsizer1 = wx.BoxSizer(wx.HORIZONTAL)
        slider = wx.Slider(panel1,
                           -1,
                           44,
                           0,
                           200,
                           size=(-1, 40),
                           style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS
                           | wx.SL_LABELS)
        slider.SetTickFreq(5, 1)
        slider.Bind(wx.EVT_SCROLL, self.OnSliderScroll)
        slider.SetToolTip(wx.ToolTip("Drag The Slider To Change The Speed!"))

        hsizer1.Add(slider, 1, wx.EXPAND)

        bsizer1.Add(self.SpeedWindow1, 1, wx.EXPAND)
        bsizer1.Add(hsizer1, 0, wx.EXPAND)
        panel1.SetSizer(bsizer1)

        # These Are Cosmetics For The Second SpeedMeter Control

        # Create The Timer For The Clock
        self.timer = wx.PyTimer(self.ClockTimer)
        self.currvalue = 0

        bsizer2 = wx.BoxSizer(wx.VERTICAL)

        hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
        stattext2 = wx.StaticText(panel2,
                                  -1,
                                  "A Simple Clock",
                                  style=wx.ALIGN_CENTER)

        button2 = wx.Button(panel2, -1, "Stop")
        self.stopped = 0
        button2.Bind(wx.EVT_BUTTON, self.OnStopClock)
        button2.SetToolTip(wx.ToolTip("Click To Stop/Resume The Clock"))

        hsizer2.Add(button2, 0, wx.LEFT, 5)
        hsizer2.Add(stattext2, 1, wx.EXPAND)

        bsizer2.Add(self.SpeedWindow2, 1, wx.EXPAND)
        bsizer2.Add(hsizer2, 0, wx.EXPAND)
        panel2.SetSizer(bsizer2)

        # These Are Cosmetics For The Third SpeedMeter Control
        self.timer3 = wx.PyTimer(self.OilTimer)

        bsizer3 = wx.BoxSizer(wx.VERTICAL)

        hsizer3 = wx.BoxSizer(wx.HORIZONTAL)
        sc = wx.SpinCtrl(panel3, -1, size=(60, 20))
        sc.SetRange(1, 250)
        sc.SetValue(50)

        self.spinctrl = sc

        strs = "Change The Speed And See How Much Fuel You Loose"
        self.spinctrl.SetToolTip(wx.ToolTip(strs))

        button3 = wx.Button(panel3, -1, "Refill!", size=(60, 20))
        button3.SetToolTip(wx.ToolTip("Click Here To Refill!"))
        button3.Bind(wx.EVT_BUTTON, self.OnRefill)

        hsizer3.Add(self.spinctrl, 0, wx.EXPAND | wx.LEFT, 5)
        hsizer3.Add(button3, 0, wx.EXPAND | wx.LEFT, 5)
        hsizer3.Add((1, 0), 2, wx.EXPAND)

        bsizer3.Add(self.SpeedWindow3, 1, wx.EXPAND)
        bsizer3.Add(hsizer3, 0, wx.EXPAND)
        panel3.SetSizer(bsizer3)

        # These Are Cosmetics For The Fourth SpeedMeter Control
        bsizer4 = wx.BoxSizer(wx.VERTICAL)

        hsizer4 = wx.BoxSizer(wx.HORIZONTAL)
        stattext4 = wx.StaticText(panel4, -1, "Use The Mouse ;-)")

        hsizer4.Add(stattext4, 1, wx.EXPAND | wx.LEFT, 5)

        bsizer4.Add(self.SpeedWindow4, 1, wx.EXPAND)
        bsizer4.Add(hsizer4, 0, wx.EXPAND)
        panel4.SetSizer(bsizer4)

        # These Are Cosmetics For The Fifth SpeedMeter Control
        bsizer5 = wx.BoxSizer(wx.VERTICAL)

        hsizer5 = wx.BoxSizer(wx.HORIZONTAL)

        button5 = wx.Button(panel5, -1, "Simulate")
        button5.SetToolTip(wx.ToolTip("Start A Car Acceleration Simulation"))
        button5.Bind(wx.EVT_BUTTON, self.OnSimulate)

        hsizer5.Add(button5, 0, wx.EXPAND | wx.LEFT, 5)
        hsizer5.Add((1, 0), 1, wx.EXPAND)

        bsizer5.Add(self.SpeedWindow5, 1, wx.EXPAND)
        bsizer5.Add(hsizer5, 0, wx.EXPAND)
        panel5.SetSizer(bsizer5)

        # These Are Cosmetics For The Sixth SpeedMeter Control
        bsizer6 = wx.BoxSizer(wx.VERTICAL)
        hsizer6 = wx.BoxSizer(wx.HORIZONTAL)

        txtctrl6 = wx.TextCtrl(panel6, -1, "60", size=(60, 20))
        txtctrl6.SetToolTip(wx.ToolTip("Insert An Angle In DEGREES"))

        self.txtctrl = txtctrl6

        button6 = wx.Button(panel6, -1, "Go!")
        button6.SetToolTip(
            wx.ToolTip("Calculate The Equivalent In Radians And Display It"))

        hsizer6.Add(txtctrl6, 0, wx.EXPAND | wx.LEFT, 5)
        hsizer6.Add(button6, 0, wx.EXPAND | wx.LEFT, 5)
        hsizer6.Add((1, 0), 1, wx.EXPAND)

        button6.Bind(wx.EVT_BUTTON, self.OnCalculate)
        bsizer6.Add(self.SpeedWindow6, 1, wx.EXPAND)
        bsizer6.Add(hsizer6, 0, wx.EXPAND)
        panel6.SetSizer(bsizer6)

        bsizer1.Layout()
        bsizer2.Layout()
        bsizer3.Layout()
        bsizer4.Layout()
        bsizer5.Layout()
        bsizer6.Layout()

        sizer.Add(panel1, 1, wx.EXPAND)
        sizer.Add(panel2, 1, wx.EXPAND)
        sizer.Add(panel3, 1, wx.EXPAND)

        sizer.Add(panel4, 1, wx.EXPAND)
        sizer.Add(panel5, 1, wx.EXPAND)
        sizer.Add(panel6, 1, wx.EXPAND)

        sizer.AddGrowableRow(0)
        sizer.AddGrowableRow(1)

        sizer.AddGrowableCol(0)
        sizer.AddGrowableCol(1)
        sizer.AddGrowableCol(2)

        panel.SetSizer(sizer)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(panel, 1, wx.EXPAND)
        self.SetSizer(mainSizer)
        mainSizer.Layout()

        self.timer.Start(1000)
        self.timer3.Start(500)
コード例 #28
0
ファイル: base_window.py プロジェクト: weswam/Gooey
 def _init_properties(self):
     # self.SetTitle(self.build_spec['program_name'])
     # self.SetSize(self.build_spec['default_size'])
     # # self.SetMinSize((400, 300))
     self.icon = wx.Icon(image_repository.program_icon, wx.BITMAP_TYPE_ICO)
     self.SetIcon(self.icon)
コード例 #29
0
    def __init__(self,
                 sync_check=False,
                 baseband_file=os.environ['HOME'] + '/FENGYUN-1D.dat',
                 frames_file=os.environ['HOME'] + '/FENGYUN-1D.hrpt',
                 decim=16,
                 satellite='FENGYUN-1D'):
        grc_wxgui.top_block_gui.__init__(
            self, title="Feng Yun 1 HRPT Baseband To Frames")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.sync_check = sync_check
        self.baseband_file = baseband_file
        self.frames_file = frames_file
        self.decim = decim
        self.satellite = satellite

        ##################################################
        # Variables
        ##################################################
        self.sym_rate = sym_rate = 600 * 1109 * 2
        self.sample_rate = sample_rate = 64e6 / decim
        self.config_filename = config_filename = os.environ[
            'HOME'] + '/.gnuradio/fy1_hrpt.conf'
        self.sps = sps = sample_rate / sym_rate
        self._saved_pll_alpha_config = ConfigParser.ConfigParser()
        self._saved_pll_alpha_config.read(config_filename)
        try:
            saved_pll_alpha = self._saved_pll_alpha_config.getfloat(
                "satname", 'pll_alpha')
        except:
            saved_pll_alpha = 0.01
        self.saved_pll_alpha = saved_pll_alpha
        self._saved_clock_alpha_config = ConfigParser.ConfigParser()
        self._saved_clock_alpha_config.read(config_filename)
        try:
            saved_clock_alpha = self._saved_clock_alpha_config.getfloat(
                "satname", 'clock_alpha')
        except:
            saved_clock_alpha = 0.01
        self.saved_clock_alpha = saved_clock_alpha
        self.sync_check_txt = sync_check_txt = sync_check
        self.satname_txt = satname_txt = satellite
        self.pll_alpha = pll_alpha = saved_pll_alpha
        self.max_clock_offset = max_clock_offset = 100e-6
        self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / sample_rate
        self.hs = hs = int(sps / 2.0)
        self.frames_file_txt = frames_file_txt = frames_file
        self.decim_txt = decim_txt = decim
        self.clock_alpha = clock_alpha = saved_clock_alpha
        self.baseband_file_txt = baseband_file_txt = baseband_file

        ##################################################
        # Notebooks
        ##################################################
        self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.displays.AddPage(grc_wxgui.Panel(self.displays),
                              "Feng Yun 1 HRPT Spectrum")
        self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information")
        self.Add(self.displays)

        ##################################################
        # Controls
        ##################################################
        self._sync_check_txt_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.sync_check_txt,
            callback=self.set_sync_check_txt,
            label="Sync check",
            converter=forms.int_converter(),
        )
        self.GridAdd(self._sync_check_txt_static_text, 0, 3, 1, 1)
        self._satname_txt_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.satname_txt,
            callback=self.set_satname_txt,
            label="Satellite",
            converter=forms.str_converter(),
        )
        self.GridAdd(self._satname_txt_static_text, 0, 0, 1, 1)
        _pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pll_alpha_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_pll_alpha_sizer,
            value=self.pll_alpha,
            callback=self.set_pll_alpha,
            label="PLL Alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._pll_alpha_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_pll_alpha_sizer,
            value=self.pll_alpha,
            callback=self.set_pll_alpha,
            minimum=0.0,
            maximum=0.5,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_pll_alpha_sizer, 1, 0, 1, 1)
        self._frames_file_txt_static_text = forms.static_text(
            parent=self.displays.GetPage(1).GetWin(),
            value=self.frames_file_txt,
            callback=self.set_frames_file_txt,
            label="Frames output filename",
            converter=forms.str_converter(),
        )
        self.displays.GetPage(1).GridAdd(self._frames_file_txt_static_text, 2,
                                         0, 1, 1)
        self._decim_txt_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.decim_txt,
            callback=self.set_decim_txt,
            label="Decimation",
            converter=forms.str_converter(),
        )
        self.GridAdd(self._decim_txt_static_text, 0, 1, 1, 1)
        _clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL)
        self._clock_alpha_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_clock_alpha_sizer,
            value=self.clock_alpha,
            callback=self.set_clock_alpha,
            label="Clock Alpha",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._clock_alpha_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_clock_alpha_sizer,
            value=self.clock_alpha,
            callback=self.set_clock_alpha,
            minimum=0.0,
            maximum=0.5,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_clock_alpha_sizer, 1, 1, 1, 1)
        self._baseband_file_txt_static_text = forms.static_text(
            parent=self.displays.GetPage(1).GetWin(),
            value=self.baseband_file_txt,
            callback=self.set_baseband_file_txt,
            label="Baseband filename",
            converter=forms.str_converter(),
        )
        self.displays.GetPage(1).GridAdd(self._baseband_file_txt_static_text,
                                         1, 0, 1, 1)

        ##################################################
        # Blocks
        ##################################################
        self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0)
        self.frame_sink = gr.file_sink(gr.sizeof_short * 1,
                                       "/home/jerry/test.hrpt")
        self.frame_sink.set_unbuffered(False)
        self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
        self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(
            sps / 2.0, clock_alpha**2 / 4.0, 0.5, clock_alpha,
            max_clock_offset)
        self.gr_file_source_0 = gr.file_source(gr.sizeof_short * 1,
                                               "/home/jerry/feng-yun-bb.dat",
                                               False)
        self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex(
        )
        self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000)
        self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0,
                                    max_carrier_offset)
        self.poesweather_fy1_hrpt_decoder_0 = poesweather.fy1_hrpt_decoder(
            True, False)
        self.poesweather_fy1_hrpt_deframer_0 = poesweather.fy1_hrpt_deframer(
            sync_check)
        self.rx_fft = fftsink2.fft_sink_c(
            self.displays.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=5,
            y_divs=10,
            ref_level=45,
            ref_scale=2.0,
            sample_rate=sample_rate,
            fft_size=1024,
            fft_rate=30,
            average=True,
            avg_alpha=0.1,
            title="Feng Yun 1 HRPT Spectrum",
            peak_hold=False,
        )
        self.displays.GetPage(0).Add(self.rx_fft.win)
        self.throttle = gr.throttle(gr.sizeof_short * 1, sample_rate * 4)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_interleaved_short_to_complex_0, 0),
                     (self.agc, 0))
        self.connect((self.throttle, 0),
                     (self.gr_interleaved_short_to_complex_0, 0))
        self.connect((self.gr_file_source_0, 0), (self.throttle, 0))
        self.connect((self.agc, 0), (self.rx_fft, 0))
        self.connect((self.agc, 0), (self.pll, 0))
        self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
        self.connect((self.gr_moving_average_xx_0, 0),
                     (self.gr_clock_recovery_mm_xx_0, 0))
        self.connect((self.gr_clock_recovery_mm_xx_0, 0),
                     (self.gr_binary_slicer_fb_0, 0))
        self.connect((self.gr_binary_slicer_fb_0, 0),
                     (self.poesweather_fy1_hrpt_deframer_0, 0))
        self.connect((self.poesweather_fy1_hrpt_deframer_0, 0),
                     (self.frame_sink, 0))
        self.connect((self.poesweather_fy1_hrpt_deframer_0, 0),
                     (self.poesweather_fy1_hrpt_decoder_0, 0))
コード例 #30
0
ファイル: MainWin.py プロジェクト: Adefx/CrossMgr
def MainLoop():
    global mainWin, redirectFileName, imageWidth, imageHeight

    app = wx.App(False)
    app.SetAppName("CrossMgrVideo")

    displayWidth, displayHeight = wx.GetDisplaySize()
    if imageWidth * 2 + 32 > displayWidth or imageHeight * 2 + 32 > displayHeight:
        imageWidth /= 2
        imageHeight /= 2

    mainWin = MainWin(None, title=AppVerName, size=(1000, 500))

    dataDir = Utils.getHomeDir()
    redirectFileName = os.path.join(dataDir, 'CrossMgrVideo.log')

    # Set up the log file.  Otherwise, show errors on the screen.
    if __name__ == '__main__':
        '''disable_stdout_buffering()'''
        pass
    else:
        try:
            logSize = os.path.getsize(redirectFileName)
            if logSize > 1000000:
                os.remove(redirectFileName)
        except:
            pass

        try:
            app.RedirectStdio(redirectFileName)
        except:
            pass

        try:
            with open(redirectFileName, 'a') as pf:
                pf.write('********************************************\n')
                pf.write(
                    '%s: %s Started.\n' %
                    (datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S'),
                     AppVerName))
        except:
            pass

    mainWin.Show()

    # Set the upper left icon.
    try:
        icon = wx.Icon(
            os.path.join(Utils.getImageFolder(), 'CrossMgrVideo.ico'),
            wx.BITMAP_TYPE_ICO)
        mainWin.SetIcon(icon)
    except:
        pass

    mainWin.Refresh()
    dlg = ConfigDialog(mainWin, mainWin.getCameraDeviceNum())
    ret = dlg.ShowModal()
    cameraDeviceNum = dlg.GetCameraDeviceNum()
    dlg.Destroy()
    if ret != wx.ID_OK:
        return

    mainWin.setCameraDeviceNum(cameraDeviceNum)

    # Start processing events.
    mainWin.Start()
    app.MainLoop()