def __init__(self, parent=None): super(Colorful, self).__init__(parent) preset_color_lay = MFlowLayout() for index, (text, color) in enumerate([ ("magenta", dayu_theme.magenta), ("red", dayu_theme.red), ("volcano", dayu_theme.volcano), ("orange", dayu_theme.orange), ("gold", dayu_theme.gold), ("lime", dayu_theme.lime), ("green", dayu_theme.green), ("cyan", dayu_theme.cyan), ("blue", dayu_theme.blue), ("geekblue", dayu_theme.geekblue), ("purple", dayu_theme.purple), ]): tag = MTag(text) tag.set_dayu_color(color) if index > 5: tag.no_border() preset_color_lay.addWidget(tag) custom_color_lay = MFlowLayout() custom_color_lay.addWidget(MTag("#f00").coloring("#f00")) custom_color_lay.addWidget(MTag("#f66").coloring("#f66")) custom_color_lay.addWidget(MTag("#f0f").coloring("#f0f").no_border()) main_lay = QVBoxLayout() main_lay.addLayout(preset_color_lay) main_lay.addLayout(custom_color_lay) self.setLayout(main_lay)
def __init__(self, parent=None): super(Colorful, self).__init__(parent) preset_color_lay = MFlowLayout() for index, (text, color) in enumerate([ ('magenta', dayu_theme.magenta), ('red', dayu_theme.red), ('volcano', dayu_theme.volcano), ('orange', dayu_theme.orange), ('gold', dayu_theme.gold), ('lime', dayu_theme.lime), ('green', dayu_theme.green), ('cyan', dayu_theme.cyan), ('blue', dayu_theme.blue), ('geekblue', dayu_theme.geekblue), ('purple', dayu_theme.purple), ]): tag = MTag(text) tag.set_dayu_color(color) if index > 5: tag.no_border() preset_color_lay.addWidget(tag) custom_color_lay = MFlowLayout() custom_color_lay.addWidget(MTag('#f00').coloring('#f00')) custom_color_lay.addWidget(MTag('#f66').coloring('#f66')) custom_color_lay.addWidget(MTag('#f0f').coloring('#f0f').no_border()) main_lay = QVBoxLayout() main_lay.addLayout(preset_color_lay) main_lay.addLayout(custom_color_lay) self.setLayout(main_lay)
def __init__(self, parent=None): super(Basic, self).__init__(parent) main_lay = QHBoxLayout() tag1 = MTag('Tag 1') tag2 = MTag('Clickable Tag').clickable() tag3 = MTag('Closeable Tag').closeable() tag2.sig_clicked.connect( functools.partial(self.slot_handle_signal, 'sig_clicked')) tag3.sig_closed.connect( functools.partial(self.slot_handle_signal, 'sig_closed')) main_lay.addWidget(tag1) main_lay.addWidget(tag2) main_lay.addWidget(tag3) main_lay.addStretch() self.setLayout(main_lay)
def __init__(self, parent=None): super(AddDeleteExampleWidget, self).__init__(parent) self.tag_lay = MFlowLayout() tag1 = MTag("Unremoveable") tag2 = MTag("Tag2").closeable() tag3 = MTag("Tag3").closeable() add_tag = MNewTag("New Tag") add_tag.sig_add_tag.connect(self.slot_add_tag) self.tag_lay.addWidget(tag1) self.tag_lay.addWidget(tag2) self.tag_lay.addWidget(tag3) self.tag_lay.addWidget(add_tag) main_lay = QHBoxLayout() main_lay.addLayout(self.tag_lay) self.setLayout(main_lay)
def __init__(self, parent=None): super(AddDelete, self).__init__(parent) self.tag_lay = MFlowLayout() tag1 = MTag('Unremoveable') tag2 = MTag('Tag2').closeable() tag3 = MTag('Tag3').closeable() add_tag = MNewTag('New Tag') add_tag.sig_add_tag.connect(self.slot_add_tag) self.tag_lay.addWidget(tag1) self.tag_lay.addWidget(tag2) self.tag_lay.addWidget(tag3) self.tag_lay.addWidget(add_tag) main_lay = QHBoxLayout() main_lay.addLayout(self.tag_lay) self.setLayout(main_lay) geo = QApplication.desktop().screenGeometry() self.setGeometry(geo.width() / 4, geo.height() / 4, geo.width() / 2, geo.height() / 2)
def slot_add_tag(self, text): tag = MTag(text).closeable() self.tag_lay.insertWidget(self.tag_lay.count() - 1, tag)