def __init__(self): gtk.Frame.__init__(self) self.modify_bg(gtk.STATE_NORMAL, get_colors("window")) self.set_size_request(180, -1) vbox = gtk.VBox() self.toolbar = ToolbarList() vbox.pack_start(self.toolbar, False, False, 0) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) vbox1 = gtk.VBox() scroll.add_with_viewport(vbox1) scroll.get_child().modify_bg(gtk.STATE_NORMAL, get_colors("window")) self.balance = BalanceWidget() vbox1.pack_start(self.balance, False, False, 0) self.lista = Lista() vbox1.pack_start(self.lista, False, False, 0) vbox.pack_start(scroll, True, True, 0) self.add(vbox) self.toolbar.connect("configview", self.__show_config) self.toolbar.connect("load", self.__load_files) self.lista.connect("button-press-event", self.__click_en_lista) self.connect("realize", self.__realized) self.show_all()
def __init__(self): gtk.EventBox.__init__(self) self.modify_bg(gtk.STATE_NORMAL, get_colors("window")) vbox = gtk.VBox() conf_box = gtk.VBox() self.balance = BalanceWidget() #self.efectos = VideoEfectos() self.lista = PlayerList() self.lista.set_mime_types(["audio/*", "video/*"]) self.player_controls = PlayerControls() conf_box.pack_start(self.balance, False, False, 0) #conf_box.pack_start(self.efectos, True, True, 0) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scroll.add_with_viewport(conf_box) scroll.get_child().modify_bg(gtk.STATE_NORMAL, get_colors("window")) vbox.pack_start(scroll, True, True, 0) vbox.pack_start(self.lista, True, True, 0) vbox.pack_end(self.player_controls, False, False, 0) self.add(vbox) self.show_all() self.balance.connect("balance-valor", self.__emit_balance) #self.efectos.connect("click_efecto", self.__emit_add_remove_efecto) #self.efectos.connect("configurar_efecto", self.__emit_config_efecto) self.lista.connect("nueva-seleccion", self.__emit_cargar_reproducir) self.lista.connect("accion-list", self.__emit_accion_list) self.lista.connect("menu_activo", self.__emit_menu_activo) self.lista.connect("add_stream", self.__emit_add_stream) self.player_controls.connect("accion-controls", self.__emit_accion_controls) self.set_size_request(150, -1)
def __init__(self, parent): # initializes the frame and its sub-frames tkinter.LabelFrame.__init__(self, parent, text="Expenditures and Balances") self.colors = None self.table_edit_listener: TableEditListener = None # create an initial balance table self.initialBalance = BalanceWidget(self, name='Initial Balance') self.initialBalance.add_listener(self) self.initialBalance.grid(row=0, padx=default_pad_x, pady=default_pad_y) # create an expenditure table self.expenditures: ExpenditureWidget = ExpenditureWidget(self) self.expenditures.add_listener(self) self.expenditures.grid(row=1, padx=default_pad_x, pady=default_pad_y) # create a final balances table self.currentBalance = BalanceWidget(self, name='Current Balance') self.currentBalance.add_listener(self) self.currentBalance.grid(row=2, padx=default_pad_x, pady=default_pad_y)
def __init__(self): gtk.EventBox.__init__(self) self.modify_bg(gtk.STATE_NORMAL, get_colors("window")) vbox = gtk.VBox() conf_box = gtk.VBox() self.balance = BalanceWidget() # self.efectos = VideoEfectos() self.lista = PlayerList() self.player_controls = PlayerControls() conf_box.pack_start(self.balance, False, False, 0) # conf_box.pack_start(self.efectos, True, True, 0) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scroll.add_with_viewport(conf_box) scroll.get_child().modify_bg(gtk.STATE_NORMAL, get_colors("window")) vbox.pack_start(scroll, True, True, 0) vbox.pack_start(self.lista, True, True, 0) vbox.pack_end(self.player_controls, False, False, 0) self.add(vbox) self.show_all() self.balance.connect("balance-valor", self.__emit_balance) # self.efectos.connect("click_efecto", self.__emit_add_remove_efecto) # self.efectos.connect("configurar_efecto", self.__emit_config_efecto) self.lista.connect("nueva-seleccion", self.__emit_cargar_reproducir) self.lista.connect("accion-list", self.__emit_accion_list) self.lista.connect("menu_activo", self.__emit_menu_activo) self.lista.connect("add_stream", self.__emit_add_stream) self.lista.connect("len_items", self.__items_in_list) self.player_controls.connect("accion-controls", self.__emit_accion_controls) self.set_size_request(150, -1)
class PlayerList(gtk.Frame): __gsignals__ = { 'accion': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT))} def __init__(self): gtk.Frame.__init__(self) self.modify_bg(gtk.STATE_NORMAL, get_colors("window")) self.set_size_request(180, -1) vbox = gtk.VBox() self.toolbar = ToolbarList() vbox.pack_start(self.toolbar, False, False, 0) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) vbox1 = gtk.VBox() scroll.add_with_viewport(vbox1) scroll.get_child().modify_bg(gtk.STATE_NORMAL, get_colors("window")) self.balance = BalanceWidget() vbox1.pack_start(self.balance, False, False, 0) self.lista = Lista() vbox1.pack_start(self.lista, False, False, 0) vbox.pack_start(scroll, True, True, 0) self.add(vbox) self.toolbar.connect("configview", self.__show_config) self.toolbar.connect("load", self.__load_files) self.lista.connect("button-press-event", self.__click_en_lista) self.connect("realize", self.__realized) self.show_all() def __show_config(self, widget, valor): self.toolbar.show() if valor: self.lista.hide() self.balance.show() else: self.balance.hide() self.lista.show() def __realized(self, widget): self.balance.hide() self.toolbar.show() self.lista.show() def __click_en_lista(self, widget, event): boton = event.button pos = (event.x, event.y) tiempo = event.time path, columna, xdefondo, ydefondo = (None, None, None, None) try: path, columna, xdefondo, ydefondo = widget.get_path_at_pos( int(pos[0]), int(pos[1])) except: return if boton == 1: return elif boton == 3: menu = MenuList( widget, boton, pos, tiempo, path, widget.get_model()) menu.connect('accion', self.__set_accion) gtk.Menu.popup(menu, None, None, None, boton, tiempo) elif boton == 2: return def __set_accion(self, widget, lista, accion, _iter): self.emit("accion", lista, accion, _iter) def __load_files(self, widget, items, tipo): if tipo == "load": self.lista.limpiar() self.toolbar.clear.set_sensitive(False) if items: self.lista.agregar_items(items) self.toolbar.clear.set_sensitive(True) def set_video(self, widget, valor): self.toolbar.config.set_sensitive(valor) if not valor and self.balance.get_visible(): self.toolbar.config.set_active(valor) self.balance.hide() self.lista.show()
class TableVisualizer(tkinter.LabelFrame, TableEditListener): # is a widget that contains the 3 tables for the basic data def __init__(self, parent): # initializes the frame and its sub-frames tkinter.LabelFrame.__init__(self, parent, text="Expenditures and Balances") self.colors = None self.table_edit_listener: TableEditListener = None # create an initial balance table self.initialBalance = BalanceWidget(self, name='Initial Balance') self.initialBalance.add_listener(self) self.initialBalance.grid(row=0, padx=default_pad_x, pady=default_pad_y) # create an expenditure table self.expenditures: ExpenditureWidget = ExpenditureWidget(self) self.expenditures.add_listener(self) self.expenditures.grid(row=1, padx=default_pad_x, pady=default_pad_y) # create a final balances table self.currentBalance = BalanceWidget(self, name='Current Balance') self.currentBalance.add_listener(self) self.currentBalance.grid(row=2, padx=default_pad_x, pady=default_pad_y) def add_listener(self, listener: TableEditListener): self.table_edit_listener = listener def load_table_data(self, databases: {str: [[]]}): # links the table to a DatabaseManager and updates the table widgets accordingly self.initialBalance.set_balances(databases['initial balances']) self.currentBalance.set_balances(databases['current balances']) self.expenditures.set_expenditures(databases['expenditures']) def send_edit_to_database(self, table_name: str, row_index: int, values): self.table_edit_listener.send_edit_to_database(table_name, row_index, values) def set_colors(self, color_dict: {str: str}): self.colors = color_dict self.update_colors() def update_colors(self): if self.colors is not None: self.config(bg=self.colors['bg_col'], fg=self.colors['text_col']) self.expenditures.set_colors(self.colors['table_col']) self.initialBalance.set_colors(self.colors['table_col']) self.currentBalance.set_colors(self.colors['table_col'])
class Derecha(gtk.EventBox): __gsignals__ = { "cargar-reproducir": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, )), "accion-list": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)), "menu_activo": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []), "add_stream": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, )), "accion-controls": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, )), 'balance-valor': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_FLOAT, gobject.TYPE_STRING)), "add_remove_efecto": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_BOOLEAN)), 'configurar_efecto': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)) } def __init__(self): gtk.EventBox.__init__(self) self.modify_bg(gtk.STATE_NORMAL, get_colors("window")) vbox = gtk.VBox() conf_box = gtk.VBox() self.balance = BalanceWidget() #self.efectos = VideoEfectos() self.lista = PlayerList() self.lista.set_mime_types(["audio/*", "video/*"]) self.player_controls = PlayerControls() conf_box.pack_start(self.balance, False, False, 0) #conf_box.pack_start(self.efectos, True, True, 0) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scroll.add_with_viewport(conf_box) scroll.get_child().modify_bg(gtk.STATE_NORMAL, get_colors("window")) vbox.pack_start(scroll, True, True, 0) vbox.pack_start(self.lista, True, True, 0) vbox.pack_end(self.player_controls, False, False, 0) self.add(vbox) self.show_all() self.balance.connect("balance-valor", self.__emit_balance) #self.efectos.connect("click_efecto", self.__emit_add_remove_efecto) #self.efectos.connect("configurar_efecto", self.__emit_config_efecto) self.lista.connect("nueva-seleccion", self.__emit_cargar_reproducir) self.lista.connect("accion-list", self.__emit_accion_list) self.lista.connect("menu_activo", self.__emit_menu_activo) self.lista.connect("add_stream", self.__emit_add_stream) self.player_controls.connect("accion-controls", self.__emit_accion_controls) self.set_size_request(150, -1) #def __emit_config_efecto(self, widget, efecto, propiedad, valor): # # Configurar efecto de video. # self.emit("configurar_efecto", efecto, propiedad, valor) #def __emit_add_remove_efecto(self, widget, efecto, valor): # # Agrega o quita efecto de video. # self.emit("add_remove_efecto", efecto, valor) def __emit_balance(self, widget, valor, prop): # brillo, contraste, saturación, hue, gamma self.emit('balance-valor', valor, prop) def __emit_accion_controls(self, widget, accion): # anterior, siguiente, pausa, play, stop self.emit("accion-controls", accion) def __emit_add_stream(self, widget, title): # El usuario agregará una dirección de streaming self.emit("add_stream", title) def __emit_menu_activo(self, widget=False): # hay un menu contextual presente self.emit("menu_activo") def __emit_accion_list(self, widget, lista, accion, _iter): # borrar, copiar, mover, grabar, etc . . . self.emit("accion-list", lista, accion, _iter) def __emit_cargar_reproducir(self, widget, path): if path: self.player_controls.activar(True) else: self.player_controls.activar(False) self.emit("cargar-reproducir", path) def show_config(self): objs = self.get_child().get_children() valor = objs[0].get_visible() if valor: ocultar(objs[0]) map(mostrar, objs[1:]) else: mostrar(objs[0]) map(ocultar, objs[1:]) def setup_init(self): ocultar(self.get_child().get_children()[0]) self.lista.setup_init() self.player_controls.activar(False) #self.efectos.cargar_efectos(list(get_jamedia_video_efectos())) def set_ip(self, valor): self.lista.set_ip(valor) def set_nueva_lista(self, archivos): self.lista.set_nueva_lista(archivos)
class Derecha(gtk.EventBox): __gsignals__ = { "cargar-reproducir": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)), "accion-list": ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT), ), "menu_activo": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []), "add_stream": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)), "accion-controls": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)), "balance-valor": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_FLOAT, gobject.TYPE_STRING)), "add_remove_efecto": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_BOOLEAN)), "configurar_efecto": ( gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT), ), } def __init__(self): gtk.EventBox.__init__(self) self.modify_bg(gtk.STATE_NORMAL, get_colors("window")) vbox = gtk.VBox() conf_box = gtk.VBox() self.balance = BalanceWidget() # self.efectos = VideoEfectos() self.lista = PlayerList() self.player_controls = PlayerControls() conf_box.pack_start(self.balance, False, False, 0) # conf_box.pack_start(self.efectos, True, True, 0) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scroll.add_with_viewport(conf_box) scroll.get_child().modify_bg(gtk.STATE_NORMAL, get_colors("window")) vbox.pack_start(scroll, True, True, 0) vbox.pack_start(self.lista, True, True, 0) vbox.pack_end(self.player_controls, False, False, 0) self.add(vbox) self.show_all() self.balance.connect("balance-valor", self.__emit_balance) # self.efectos.connect("click_efecto", self.__emit_add_remove_efecto) # self.efectos.connect("configurar_efecto", self.__emit_config_efecto) self.lista.connect("nueva-seleccion", self.__emit_cargar_reproducir) self.lista.connect("accion-list", self.__emit_accion_list) self.lista.connect("menu_activo", self.__emit_menu_activo) self.lista.connect("add_stream", self.__emit_add_stream) self.lista.connect("len_items", self.__items_in_list) self.player_controls.connect("accion-controls", self.__emit_accion_controls) self.set_size_request(150, -1) # def __emit_config_efecto(self, widget, efecto, propiedad, valor): # # Configurar efecto de video. # self.emit("configurar_efecto", efecto, propiedad, valor) # def __emit_add_remove_efecto(self, widget, efecto, valor): # # Agrega o quita efecto de video. # self.emit("add_remove_efecto", efecto, valor) def __items_in_list(self, widget, items): self.player_controls.activar(items) def __emit_balance(self, widget, valor, prop): # brillo, contraste, saturación, hue, gamma self.emit("balance-valor", valor, prop) def __emit_accion_controls(self, widget, accion): # anterior, siguiente, pausa, play, stop self.emit("accion-controls", accion) def __emit_add_stream(self, widget, title): # El usuario agregará una dirección de streaming self.emit("add_stream", title) def __emit_menu_activo(self, widget=False): # hay un menu contextual presente self.emit("menu_activo") def __emit_accion_list(self, widget, lista, accion, _iter): # borrar, copiar, mover, grabar, etc . . . self.emit("accion-list", lista, accion, _iter) def __emit_cargar_reproducir(self, widget, path): self.emit("cargar-reproducir", path) def show_config(self): objs = self.get_child().get_children() valor = objs[0].get_visible() if valor: ocultar(objs[0]) map(mostrar, objs[1:]) else: mostrar(objs[0]) map(ocultar, objs[1:]) def setup_init(self): ocultar(self.get_child().get_children()[0]) self.lista.setup_init() self.player_controls.activar(0) # self.efectos.cargar_efectos(list(get_jamedia_video_efectos())) def set_ip(self, valor): self.lista.set_ip(valor) def set_nueva_lista(self, archivos): self.lista.set_nueva_lista(archivos)