Ejemplo n.º 1
0
    def __init__(self, bot, stream):
        self.root = tk.Tk()
        self.root.title('Discord Audio Pipe')

        self.bot = bot
        self.voice = None
        self.stream = stream

        self.cred = tk.Label(self.root, text='Connecting...', fg='black')
        self.cred.grid(row=0, column=0, columnspan=2, sticky='W')

        tk.Label(self.root, text='Device', fg='black').grid(row=1, column=0)
        tk.Label(self.root, text='Server', fg='black').grid(row=1, column=1)
        tk.Label(self.root, text='Channel', fg='black').grid(row=1, column=2)

        device_options = sound.query_devices()
        self.dv = tk.StringVar(self.root)
        self.dv.trace(
            'w', lambda *args: self.change_device(device_options, self.dv))
        self.dv.set(device_options.get(0))
        self.device = tk.OptionMenu(self.root, self.dv, *device_options)
        self.device.grid(row=2, column=0)

        self.sv = tk.StringVar(self.root)
        self.sv.trace(
            'w', lambda *args: asyncio.ensure_future(self.change_server()))
        self.sv.set('None')
        self.server = tk.OptionMenu(self.root, self.sv, 'None')
        self.server.grid(row=2, column=1)
        self.server_map = {}

        self.cv = tk.StringVar(self.root)
        self.cv.trace(
            "w", lambda *args: asyncio.ensure_future(self.change_channel()))
        self.cv.set('None')
        self.channel = tk.OptionMenu(self.root, self.cv, 'None')
        self.channel.grid(row=2, column=2)
        self.channel_map = {}

        self.mv = tk.StringVar(self.root)
        self.mv.set('Mute')
        self.mute = tk.Button(self.root,
                              textvariable=self.mv,
                              command=self.toggle_mute)
        self.mute.grid(row=2, column=3, padx=5)

        self.root.protocol('WM_DELETE_WINDOW',
                           lambda: asyncio.ensure_future(self.exit()))
Ejemplo n.º 2
0
    def __init__(self, app, bot):
        # app
        super(GUI, self).__init__()
        QDir.setCurrent(bundle_dir)
        self.app = app

        # window info
        self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
        window_icon = QIcon("./assets/favicon.ico")
        self.setWindowTitle("Discord Audio Pipe")
        self.app.setWindowIcon(window_icon)
        self.position = None

        # discord
        self.bot = bot

        # layout
        central = QWidget()
        self.layout = QGridLayout()
        central.setLayout(self.layout)

        # labels
        self.info = QLabel("Connecting...")
        device_lb = QLabel("Devices")
        device_lb.setObjectName("label")
        server_lb = QLabel("Servers     ")
        server_lb.setObjectName("label")
        channel_lb = QLabel("Channels  ")
        channel_lb.setObjectName("label")

        # connections
        self.devices = sound.query_devices()
        self.connections = [Connection(2, self)]
        self.connected_servers = set()

        # new connections
        self.connection_btn = QPushButton("+", self)
        self.connection_btn.setObjectName("connection_btn")

        # add widgets
        self.layout.addWidget(self.info, 0, 0, 1, 3)
        self.layout.addWidget(device_lb, 1, 0)
        self.layout.addWidget(server_lb, 1, 1)
        self.layout.addWidget(channel_lb, 1, 2)
        self.layout.addWidget(self.connection_btn, 2, 4)

        # events
        self.connection_btn.clicked.connect(self.add_connection)

        # build window
        titlebar = TitleBar(self)
        self.setMenuWidget(titlebar)
        self.setCentralWidget(central)
        self.setEnabled(False)

        # load styles
        QFontDatabase.addApplicationFont("./assets/Roboto-Black.ttf")
        with open("./assets/style.qss", "r") as qss:
            self.app.setStyleSheet(qss.read())

        # show window
        self.show()
Ejemplo n.º 3
0
    def __init__(self, app, bot, stream):
        # app
        super(GUI, self).__init__()
        QDir.setCurrent(bundle_dir)
        self.app = app

        # window info
        self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
        window_icon = QIcon('./assets/favicon.ico')
        self.setWindowTitle('Discord Audio Pipe')
        self.app.setWindowIcon(window_icon)
        self.position = None

        # discord
        self.bot = bot
        self.voice = None
        self.stream = stream

        # layout
        central = QWidget()
        layout = QGridLayout()
        central.setLayout(layout)

        # loading
        self.info = QLabel('Connecting...')
        self.loading = QSvgWidget('./assets/loading.svg')

        # devices
        self.devices = QComboBox(self)
        self.devices.setItemDelegate(QStyledItemDelegate())
        self.devices.setPlaceholderText('None')
        device_lb = QLabel('Devices')
        device_lb.setObjectName('label')

        for device, idx in sound.query_devices().items():
            self.devices.addItem(device + '   ', idx)

        # servers
        self.servers = QComboBox(self)
        self.servers.setItemDelegate(QStyledItemDelegate())
        self.servers.setPlaceholderText('None')
        server_lb = QLabel('Servers     ')
        server_lb.setObjectName('label')

        # channels
        self.channels = QComboBox(self)
        self.channels.setItemDelegate(QStyledItemDelegate())
        self.channels.setPlaceholderText('None')
        channel_lb = QLabel('Channels  ')
        channel_lb.setObjectName('label')

        # mute
        self.mute = QPushButton('Mute', self)
        self.mute.setObjectName('mute')

        # add widgets
        layout.addWidget(self.info, 0, 0, 1, 3)
        layout.addWidget(self.loading, 0, 3, alignment=Qt.AlignHCenter)
        layout.addWidget(device_lb, 1, 0)
        layout.addWidget(self.devices, 2, 0)
        layout.addWidget(server_lb, 1, 1)
        layout.addWidget(self.servers, 2, 1)
        layout.addWidget(channel_lb, 1, 2)
        layout.addWidget(self.channels, 2, 2)
        layout.addWidget(self.mute, 2, 3)

        # events
        self.devices.currentTextChanged.connect(self.change_device)
        self.servers.currentTextChanged.connect(
            lambda: asyncio.ensure_future(self.change_server()))
        self.channels.currentTextChanged.connect(
            lambda: asyncio.ensure_future(self.change_channel()))
        self.mute.clicked.connect(self.toggle_mute)

        # build window
        titlebar = TitleBar(self)
        self.setMenuWidget(titlebar)
        self.setCentralWidget(central)
        self.disable_ui()

        # load styles
        QFontDatabase.addApplicationFont('./assets/Roboto-Black.ttf')
        with open('./assets/style.qss', 'r') as qss:
            self.app.setStyleSheet(qss.read())

        # show window
        self.show()