Untitled

mail@pastecode.io avatar
unknown
python
a year ago
2.1 kB
2
Indexable
Never
```def callback_whisper(uuid: UUID, data: dict) -> None:

    print('Foi resgatado um reward ' + str(RedempPubsub))
    print(data['data']['redemption']['user_input'])

    redemuserimput = data['data']['redemption']['user_input']

    def imputuser():
        return redemuserimput

class ttkTimer(Thread):
    """a class serving same function as wxTimer... but there may be better ways to do this
    """
    def __init__(self, callback, tick):
        Thread.__init__(self)
        self.callback = callback
        #print("callback= ", callback())
        self.stopFlag = Event()
        self.tick = tick
        self.iters = 0

    def run(self):
        while not self.stopFlag.wait(self.tick):
            self.iters += 1
            self.callback()
            #print("ttkTimer start")

    def stop(self):
        self.stopFlag.set()

    def get(self):
        return self.iters

class Player(Tk.Frame):
    """The main window has to deal with events.
    """

    def __init__(self, parent, title=None):
        Tk.Frame.__init__(self, parent)
    
        self.parent = parent

        if title == None:
            title = "tk_vlc"
        self.parent.title(title)

        # Menu Bar
        #   File Menu
        menubar = Tk.Menu(self.parent)
        self.parent.config(menu=menubar) 


        ctrlpanel = ttk.Frame(self.parent)
        pause  = ttk.Button(ctrlpanel, text="Pause", command=self.OnPause)
        stop   = ttk.Button(ctrlpanel, text="Stop", command=self.OnStop)
        pause.pack(side=Tk.LEFT)
        stop.pack(side=Tk.LEFT)
        ctrlpanel.pack(side=Tk.BOTTOM)


        # VLC player controls
        self.Instance = vlc.Instance()
        self.player = self.Instance.media_player_new()

        query_string = urllib.parse.urlencode({"search_query": imputuser})
        formaturl = urllib.request.urlopen("https://www.youtube.com/results?" + query_string)
        search_results = re.findall(r"watch\?v=(\S{11})", formaturl.read().decode())
        clip2 = "https://www.youtube.com/watch?v=" + "{}".format(search_results[0])