示例#1
0
def demo():
    # alternatively you could use
    #app = wx.App()
    # InspectableApp is a great debug tool, see:
    # http://wiki.wxpython.org/Widget%20Inspection%20Tool
    app = wit.InspectableApp()
    frame = wx.Frame(None, -1, 'Plotter')
    plotter = PlotNotebook(frame)
    fig1 = plotter.add('figure 1')
    axes1 = fig1.gca()
    l1, = axes1.plot([1, 2, 3], [2, 1, 4])

    def toggle_line(event):
        l1.set_visible(not l1.get_visible())
        fig1.canvas.draw()  ## important for refreshing the display

    ## From https://matplotlib.org/users /event_handling.html
    cid = fig1.canvas.mpl_connect('button_press_event',
                                  toggle_line)  ## cid is an integer
    print("cid: " + str(cid))

    axes2 = plotter.add('figure 2').gca()
    axes2.plot([1, 2, 3, 4, 5], [2, 1, 4, 2, 3])
    frame.Show()
    app.MainLoop()
示例#2
0
def viewPdfBytes(file):
    app = WIT.InspectableApp(redirect=False)
    pdfV = PDFViewer(None, size=(1200, 800))
    file_like_object = io.BytesIO(file)
    pdfV.viewer.LoadFile(file_like_object)
    pdfV.Show()
    app.MainLoop()
示例#3
0
def demo():
    # alternatively you could use
    #app = wx.App()
    # InspectableApp is a great debug tool, see:
    # http://wiki.wxpython.org/Widget%20Inspection%20Tool
    app = wit.InspectableApp()
    frame = wx.Frame(None, -1, 'Plotter')
    plotter = PlotNotebook(frame)
    frame.Show()
    app.MainLoop()
示例#4
0
def demo():
    # alternatively you could use
    #app = wx.App()
    # InspectableApp is a great debug tool, see:
    # http://wiki.wxpython.org/Widget%20Inspection%20Tool
    app = wit.InspectableApp()
    frame = wx.Frame(None, -1, 'Plotter')
    plotter = PlotNotebook(frame)
    axes1 = plotter.add('figure 1').gca()
    axes1.plot([1, 2, 3], [2, 1, 4])
    axes2 = plotter.add('figure 2').gca()
    axes2.plot([1, 2, 3, 4, 5], [2, 1, 4, 2, 3])
    frame.Show()
    app.MainLoop()
示例#5
0
def demo():
    # alternatively you could use
    #app = wx.App()
    # InspectableApp is a great debug tool, see:
    # http://wiki.wxpython.org/Widget%20Inspection%20Tool
    app = wit.InspectableApp()
    frame = wx.Frame(None, -1, 'Plotter')
    plotter = PlotNotebook(frame)
    page1(plotter)
    page2(plotter)
    if Axes3D:
        page3d(plotter)
    page4(plotter)
    frame.SetMinSize((400, 400))

    frame.Show()
    app.MainLoop()
示例#6
0
 def test_App(self):
     app = wit.InspectableApp()
示例#7
0
            GNU General Public License for more details.\n
            You should have received a copy of the GNU General Public License
            along with this program. If not, see <https://www.gnu.org/licenses/>."""
 
        abt = wx.MessageDialog(self, abt_text, 'About StrEmbed-5-1', wx.OK)
        abt.ShowModal()         # Shows dialogue that stops process (modal)
        abt.Destroy()



    def OnExit(self, event):

        self.Close(True)        # Close program



    def OnResize(self, event):

        # Display window size in status bar
        self.statbar.SetStatusText("Window size = " + format(self.GetSize()))
        event.Skip()



if __name__ == '__main__':
    app = wit.InspectableApp()
    frame = MainWindow()
    frame.Show()
    frame.Maximize()
    app.MainLoop()
示例#8
0
文件: app.py 项目: JoenyBui/crane-app
    from crane.controller.main import CraneController
    from crane.model.project import CraneProject

    import docx
    import docxtpl

    setting = Setting()

    def exit_application(event):
        exit()

    # Initialize Application
    # Use Ctrl-Alt-I to open the Widget Inspection Tool
    # http://wiki.wxpython.org/Widget%20Inspection%20Tool
    app = WIT.InspectableApp()

    # Check if the a file path is passed with the executable.
    project = CraneProject()
    controller = CraneController(project,
                                 master_key=MASTER_KEY,
                                 setting=setting)
    frame = MainWindow(parent=None,
                       controller=controller,
                       title='Crane',
                       style=(wx.DEFAULT_FRAME_STYLE | wx.WS_EX_CONTEXTHELP),
                       width=1400,
                       height=800)

    # Set Components.
    controller.initialize_notebook(frame)
示例#9
0
class PdfAttempt(sc.SizedFrame):
    def __init__(self, parent, **kwds):
        super(PdfAttempt, self).__init__(parent, **kwds)

        paneCont = self.GetContentsPane()
        self.buttonpanel = pdfButtonPanel(paneCont, wx.NewId(),
                                          wx.DefaultPosition, wx.DefaultSize,
                                          0)
        self.buttonpanel.SetSizerProps(expand=True)
        self.viewer = pdfViewer(paneCont, wx.NewId(), wx.DefaultPosition,
                                wx.DefaultSize,
                                wx.HSCROLL | wx.VSCROLL | wx.SUNKEN_BORDER)
        self.viewer.UsePrintDirect = False
        self.viewer.SetSizerProps(expand=True, proportion=1)

        # introduce buttonpanel and viewer to each other
        self.buttonpanel.viewer = self.viewer
        self.viewer.buttonpanel = self.buttonpanel


if __name__ == '__main__':
    import wx.lib.mixins.inspection as WIT
    app = WIT.InspectableApp(redirect=False)

    pdfV = PdfAttempt(None, size=(800, 600))
    pdfV.viewer.UsePrintDirect = False
    pdfV.viewer.LoadFile('rfc8.pdf')
    pdfV.Show()

    app.MainLoop()
def demo():
    def onselect(eclick, erelease):
        global coordinate_new
        print('startposition: (%f, %f)' % (eclick.xdata, eclick.ydata))
        print('endposition  : (%f, %f)' % (erelease.xdata, erelease.ydata))
        print('used button  : ', eclick.button)
        coordinate_new=toggle_selector.RS.geometry
        coordinate_new=coordinate_new.astype(int)
        print(coordinate_new)
    
    

    def toggle_selector(event):
        global coorinate_new
        print('Key pressed.')
        if event.key in ['Q', 'q'] and toggle_selector.RS.active:
            print('RectangleSelector deactivated.')
            toggle_selector.RS.set_active(False)
        if event.key in ['A', 'a'] and not toggle_selector.RS.active:
            print('RectangleSelector activated.')
            toggle_selector.RS.set_active(True)
        if event.key in ['D', 'd'] and toggle_selector.RS.active:
            save_image(coordinate_new)
    # alternatively you could use
    #app = wx.App()
    # InspectableApp is a great debug tool, see:
    # http://wiki.wxpython.org/Widget%20Inspection%20Tool
    data = np.load('D:\\test1.npy')
    app = wit.InspectableApp()
    frame = wx.Frame(None, -1, 'Plotter')
    plotter = PlotNotebook(frame)
    
    axes1 = plotter.add(number=1,name='figure 1').gca()
    img1=axes1.imshow(data[1])
    Plot.figure.colorbar(img1, ax=axes1)
    #axes1.colorbar.ColorbarBase(ax=axes1, cmap=cm.Greys, 
                                # orientation="vertical")
    plt.subplot(1,2,2)
    plt.imshow(data[4000])
    plt.colorbar()
    axes1 = plotter.add(number=2,name='figure 1').gca()
    axes1.imshow(data[4000])
    
    #plt.subplot(1,2,2)
    #plt.plot([1, 2, 3, 4, 5], [2, 1, 4, 2, 3])
    
    toggle_selector_RS = RectangleSelector(axes1, onselect, drawtype='box',
                                            #minspanx=5, minspany=5, 
                                            spancoords='data', interactive=True, 
                                            )
    Plot.figure.canvas.mpl_connect('key_press_event', toggle_selector)
        
    
            
    rectprops = dict(facecolor='red', edgecolor = 'black',
                     alpha=0.2, fill=True)
                     
    
    #plt.subplot(1,2,1)
    #plt.plot([1, 2, 3], [2, 1, 4])
    #Plot.fig2.plot([1, 2, 3, 4, 5], [2, 1, 4, 2, 3])
    

    frame.Show()
    app.MainLoop()
示例#11
0
def main(startf="135000000", endf="t150000000", step_size="500000", xtick=0.5, ytick=0.1):
    # ser = serial.Serial('/dev/ttyACM0')

    # auto-detect antuino port
    """
    $ lsusb
    ...
    $ Bus 001 Device 022: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
    ...
    """

    ports = list(serial.tools.list_ports.comports())
    found = None
    for p in ports:
        if p.vid == 0x1a86:
            found = p
            device = p.device
            break

    if not found:
        print("I couldn't find a connected antuino. Exiting!")
        time.sleep(4)
        sys.exit(0)

    ser = serial.Serial(device, baudrate=9600)  # Arduino Nano v2 clone on Linux
    # ser.flushInput()

    # wait for the connection to settle down
    time.sleep(3)

    ser.write(b"s%s\n" % step_size.encode("ascii"))
    ser.write(b"f%s\n" % startf.encode("ascii"))
    ser.write(b"t%s\n" % endf.encode("ascii"))

    ser.write(b"g\n")

    ser.flushInput()

    values = []

    frequencies = []
    swrs = []

    while True:
        line = ser.readline().strip()
        line = line.decode("ascii")
        print(line)

        if "end" in line:
            break

        try:
            marker, frequency, something, swr = line.split(":")
        except:
            pass
            continue

        swr = int(swr) / 10.0
        frequency = int(frequency) / 1000000.0

        print(frequency, swr)
        values.append((frequency, swr))
        frequencies.append(frequency)
        swrs.append(swr)


    print(values)
    print(frequencies)
    print(swrs)

    timestr = time.strftime("%Y%m%d-%H%M%S")
    with open("logbook-%s.py" % timestr, "w") as f:
        f.write(template % (frequencies, swrs))

    # draw graph
    app = wit.InspectableApp()
    frame = wx.Frame(None, -1, 'AntuinoTerm', size=(1024,768))
    plotter = PlotNotebook(frame)
    ax = plotter.add('SWR sweep').gca()
    ax.plot(frequencies, swrs)
    start, end = ax.get_xlim()
    starty, endy = ax.get_ylim()
    ax.xaxis.set_ticks(np.arange(start, end, xtick))
    ax.xaxis.set_major_formatter(ticker.FormatStrFormatter('%0.1f'))
    ax.yaxis.set_ticks(np.arange(starty, endy, ytick))
    ax.yaxis.set_major_formatter(ticker.FormatStrFormatter('%0.1f'))

    frame.Show()
    app.MainLoop()