def __init__(self, loc, title='Worksheet Settings', update_func=None): super().__init__(loc, title, update_func) settings = [ self.create_setting(name, active) for name, active in self.settings.items() ] fill_layout(self.layout, *settings)
def __init__(self, loc='config/pos.json', title='Part of Speech Settings'): super().__init__(loc, title) self.labels = {} settings = [ self.create_setting(name, style) for name, style in self.settings.items() ] fill_layout(self.layout, *settings)
def add_line(self): hbox = QHBoxLayout() box = create_text_box() self.lines.append(box) btn = create_remove_btn(lambda: self.remove_line(hbox, box, btn)) index = self.size fill_layout(hbox, box, btn) self.layout.insertLayout(index, hbox) self.size += 1
def initUI(self): QToolTip.setFont(QFont('SansSerif', 10)) self.statusBar().showMessage('Ready') self.load_components() self.set_layout() self.add_toolbar() vbox = QVBoxLayout() vbox.addStretch(2) vbox.addWidget(self.controller) fill_layout(self.layout, self.lines, vbox)
def create_setting(self, pos, style): layout = QHBoxLayout() color = style['rgb'] name = style['name'] active = style['active'] self.labels[pos] = self._create_label(name, color) btn = self._create_btn(pos) checkbox = QCheckBox("Activate") checkbox.setChecked(active) checkbox.stateChanged.connect(lambda _, p=pos: self.update_status(p)) fill_layout(layout, self.labels[pos], btn, checkbox) return layout
def __init__(self, lines_func): super().__init__() self.lines_func = lines_func self.layout = QVBoxLayout(self) self.input = QTextEdit() btn_layout = QHBoxLayout() btn_layout.addStretch(2) fill_layout(btn_layout, create_btn('Choose File', self.load_file), create_btn('Import', self.send_lines)) fill_layout(self.layout, self.input, btn_layout)
def __init__(self, reset_func=None): super().__init__() self.size = 0 self.reset_func = reset_func self.layout = QVBoxLayout() self.lines = [] for i in range(10): self.add_line() layout = self.get_layout() add_btn = create_control_btn('Add', self.add_line) clear_btn = create_control_btn('Reset', self.reset) fill_layout(layout, add_btn, clear_btn)
def __init__(self, news_data, web_data, generate_func, link_func, lines_func): super().__init__() self.lines_func = lines_func self.layout = self.init_layout() self.topic_controller = TopicController(news_data, link_func, lines_func) self.web_controller = TopicController(web_data, link_func, lines_func, manual=False) fill_layout( self.layout, create('Import', self.show_file_manager), # create('Web', self.show_web), create('News', self.show_news), create('Generate', generate_func))
def __init__(self, topic, articles, lines_func): super().__init__() self.lines_func = lines_func self.articles = articles self.layout = QVBoxLayout(self) grid = QGridLayout() grid.setSpacing(10) title = create_label('Category: {}'.format(topic)) for index, article in enumerate(self.articles): label = LinkLabel(article['title'].strip(), article['url'], font_size=12) callback = lambda _, id=article['id'], link=article[ 'url']: self.send_lines(id, link) btn = create_btn('Add', callback, style='secondary') grid.addWidget(label, index + 1, 0) grid.addWidget(btn, index + 1, 1) fill_layout(self.layout, title, grid)
import sys