Пример #1
0
class TestPanel(wx.Panel):
    __test__ = False

    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1)
        self.pdf = None

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

        from wx.lib.flashwin import FlashWindow
        self.flash = FlashWindow(self, style=wx.SUNKEN_BORDER)

        vars = '?c=abcde12345&STATE=creator'

        url = 'http://w.digsby.com/dw.swf'  #?STATE=creator&field=ffffff&statustext=777777&nick=my.nickname&bgcolor=eaeaea&text=444444&title=Digsby+Widget&titletext=7a7a7a'
        url += vars

        self.flash.LoadMovie(0, url)
        #self.flash.LoadMovie(0, 'file://' + os.path.abspath('c:/dev/wxPython/demo/data/Asteroid_blaster.swf'))
        sizer.Add(self.flash, proportion=1, flag=wx.EXPAND)

        btn = wx.Button(self, wx.NewId(), "Open Flash File")
        self.Bind(wx.EVT_BUTTON, self.OnOpenFileButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "Open Flash URL")
        self.Bind(wx.EVT_BUTTON, self.OnOpenURLButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)

        btnSizer.Add((50, -1), proportion=2, flag=wx.EXPAND)
        sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)

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

    def OnOpenFileButton(self, event):
        dlg = wx.FileDialog(self, wildcard="*.swf")

        if dlg.ShowModal() == wx.ID_OK:
            wx.BeginBusyCursor()
            self.flash.LoadMovie(0, 'file://' + dlg.GetPath())
            wx.EndBusyCursor()

        dlg.Destroy()

    def OnOpenURLButton(self, event):
        dlg = wx.TextEntryDialog(self, "Enter a URL of a .swf file",
                                 "Enter URL")

        if dlg.ShowModal() == wx.ID_OK:
            wx.BeginBusyCursor()
            # setting the movie property works too
            self.flash.movie = dlg.GetValue()
            wx.EndBusyCursor()

        dlg.Destroy()
Пример #2
0
class TestPanel(wx.Panel):
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, style=0)
        self.pdf = None

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

        self.flash = FlashWindow(self, style=wx.SUNKEN_BORDER)
        self.flash.LoadMovie(0, 'file://' + os.path.abspath('data/Asteroid_blaster.swf'))

        sizer.Add(self.flash, proportion=1, flag=wx.EXPAND)

        btn = wx.Button(self, wx.NewId(), "Open Flash File")
        self.Bind(wx.EVT_BUTTON, self.OnOpenFileButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "Open Flash URL")
        self.Bind(wx.EVT_BUTTON, self.OnOpenURLButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)

        btnSizer.Add((50,-1), proportion=2, flag=wx.EXPAND)
        sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)

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



    def OnOpenFileButton(self, event):
        dlg = wx.FileDialog(self, wildcard="*.swf")

        if dlg.ShowModal() == wx.ID_OK:
            wx.BeginBusyCursor()
            self.flash.LoadMovie(0, 'file://' + dlg.GetPath())
            wx.EndBusyCursor()

        dlg.Destroy()


    def OnOpenURLButton(self, event):
        dlg = wx.TextEntryDialog(self, "Enter a URL of a .swf file", "Enter URL")

        if dlg.ShowModal() == wx.ID_OK:
            wx.BeginBusyCursor()
            # setting the movie property works too
            self.flash.movie = dlg.GetValue()
            wx.EndBusyCursor()

        dlg.Destroy()
Пример #3
0
class _FlashEditor(Editor):
    """Traits UI Flash editor."""

    # -------------------------------------------------------------------------
    #  Trait definitions:
    # -------------------------------------------------------------------------

    #: Is the table editor is scrollable? This value overrides the default.
    scrollable = True

    def init(self, parent):
        """Finishes initializing the editor by creating the underlying toolkit
        widget.
        """
        self.control = FlashWindow(parent)
        self.set_tooltip()

    def update_editor(self):
        """Updates the editor when the object trait changes externally to the
        editor.
        """
        value = self.str_value.strip()
        if value.find("://") < 0:
            value = "file://" + value

        wx.BeginBusyCursor()
        self.control.LoadMovie(0, value)
        wx.EndBusyCursor()
class MyPanel(wx.Panel):
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, -1)
        self.pdf = None

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

        self.flash = FlashWindow(self, style=wx.SUNKEN_BORDER)
        sizer.Add(self.flash, proportion=1, flag=wx.EXPAND)

        btn = wx.Button(self, wx.NewId(), "Open a Flash File")
        self.Bind(wx.EVT_BUTTON, self.OnOpenFileButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)

        btn = wx.Button(self, wx.NewId(), "Open a Flash URL")
        self.Bind(wx.EVT_BUTTON, self.OnOpenURLButton, btn)
        btnSizer.Add(btn, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)

        btnSizer.Add((50, -1), proportion=2, flag=wx.EXPAND)
        sizer.Add(btnSizer, proportion=0, flag=wx.EXPAND)

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

    def OnOpenFileButton(self, event):
        # make sure you have flash files available on drive
        # dlg = wx.FileDialog(self, wildcard="*.swf")
        dlg = wx.FileDialog(self)

        if dlg.ShowModal() == wx.ID_OK:
            wx.BeginBusyCursor()
            self.flash.LoadMovie(0, 'file://' + dlg.GetPath())
            wx.EndBusyCursor()
        dlg.Destroy()

    def OnOpenURLButton(self, event):
        # you can retrieve flash files from internet too
        dlg = wx.TextEntryDialog(self, "Enter a URL of a .swf file",
                                 "Enter URL")
        if dlg.ShowModal() == wx.ID_OK:
            wx.BeginBusyCursor()
            # setting the movie property works too
            self.flash.movie = dlg.GetValue()
            wx.EndBusyCursor()
        dlg.Destroy()
Пример #5
0
class Form(gui.form_ui):
    def __init__(self, parent=None):
        gui.form_ui.__init__(self, parent)
        self.t_likes.SetLabel("0")
        if wx.Platform == '__WXMSW__':
            from wx.lib.flashwin import FlashWindow
            self.flash = FlashWindow(self, style=wx.SUNKEN_BORDER)
            self.canvas.Add(self.flash, proportion=1, flag=wx.EXPAND, border=5)
        self.conn = connect("wanga_detail.db")
        self.curs = self.conn.cursor()
        self.gamelist.InsertColumn(0, u'序号', width=50)
        w = self.gamelist.GetSizeTuple()[0]  #width of listctrl
        self.gamelist.InsertColumn(1, u'游戏名', width=w - 75)
        self.gamelist.InsertColumn(2, 'id', width=0)
        self.gamelist.InsertColumn(3, 'src', width=0)
        self.update_list(
            self.curs.execute('select name,id,src,likes from gamelist'))

    def set(self, event):
        pass

    def update_list(self, ans):
        n = ans.fetchall()
        line = 0
        self.gamelist.DeleteAllItems()
        for item in n:
            self.gamelist.InsertStringItem(line, str(line + 1))
            self.gamelist.SetStringItem(line, 1, item[0])
            self.gamelist.SetStringItem(line, 2, str(item[1]))
            self.gamelist.SetStringItem(line, 3, item[2])
            line = line + 1

    def search(self, event):
        q1 = '%' + self.t_name.GetValue() + '%'
        q2 = '%' + self.t_tag.GetValue() + '%'
        q3 = '%' + self.t_type.GetValue() + '%'
        cmd='select name,id,src,likes from gamelist '\
        'where name like ? and tag like ? and type like ?;'
        self.update_list(self.curs.execute(cmd, (q1, q2, q3)))

    def likes(self, event):
        n = int(self.t_likes.GetLabel())
        self.t_likes.SetLabel("%d" % (n + 1))
        pass

    def run_game(self, event):
        pass

    def show_msg(self, event):
        n = event.m_itemIndex
        id = self.gamelist.GetItem(n, 2).GetText()
        src = self.gamelist.GetItem(n, 3).GetText()
        s = "id:%s\nsrc:%s" % (id, src)
        self.m_msg.SetValue(s)
        swfname = os.path.basename(s)
        fullname = os.path.join(sys.path[0], datadir, swfname)
        if os.path.exists(fullname):
            src = fullname
            print(src)
        else:
            cache_grab.grab_file(swfname, datadir)
        self.flash.LoadMovie(0, src)