def __init__(self, text, *args, **kwargs): super().__init__(*args, **kwargs) self.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.setText(text) self.setLineWidth(1) self.setFrameShape(QtWidgets.QFrame.Box) self.freeze = False t.style(self, background=TOOLTIP_DRK_BG, color=TITLE_WHITE) self.show()
def __init__(self, place, path, width, partner): super().__init__(place) self.partner = partner pixmap = QtCore.QPixmap(path).scaledToWidth( width, QtCore.Qt.SmoothTransformation) playspace = partner.width() - width self.random = random.randint(0, playspace) t.pos(self, size=pixmap) t.style(self, background=TRANSPARENT) self.setPixmap(pixmap) self.show()
def build_tiplabel(self, text, fontsize=None, width=None): if self.tiplabel or not self.lineedit: return self.tiplabel = t.pos(new=self.lineedit, inside=self.lineedit) self.tiplabel.width_size = width self.tiplabel.setText(text) if fontsize: t.style(self.tiplabel, font=fontsize) self.tiplabel.font_size = fontsize else: self.tiplabel.font_size = t.correct_broken_font_size(self.tiplabel) t.style(self.tiplabel, color=TIPTEXT, background='transparent')
def __init__(self, edge, width, height, button_width=0, canvas_border=0, canvas_background='transparent', *args, **kwargs): super().__init__(*args, **kwargs) self.edge = edge self.canvas_border = canvas_border self.button_width = button_width t.pos(self, size=[height, width]) t.style(self, background=canvas_background)
def text_changed(self): text = self.text().strip() if text and os.path.exists(text): self.save(data=text) if not self.activated: t.style(self, color='white') self.activation_toggle(force=True, save=False) # already saved if self.signal: self.signal.activated.emit() else: if self.activated: t.style(self, color='gray') self.activation_toggle(force=False, save=False) if self.signal: self.signal.deactivated.emit()
def make_title(self, text, height=28, width=500, font=14): self.title = self.TITLE(place=self.toolplate, text=text, parent=self, main=self.main, drops=True) self.title.filesdropped = self.filesdropped self.title.setText(text) self.toolplate.widgets.append(self.title) t.style(self.title, font=font) w = t.shrink_label_to_text(self.title, no_change=True, x_margin=12) if w < width * 0.65: w = width * 0.65 t.pos(self.title, height=height) t.pos(self, width=w)
def highlight_toggle(self, string=None): if string == self.type: if self.activated: t.style(self, **self.activated_on) else: t.style(self, **self.deactivated_on) else: if self.activated: t.style(self, **self.activated_off) else: t.style(self, **self.deactivated_off)
def __init__(self, activated_on=None, activated_off=None, deactivated_on=None, deactivated_off=None, label_background='white', label_foreground='black', *args, **kwargs): super().__init__(activated_on=activated_on or dict(color=TEXT_ON), activated_off=activated_off or dict(color=TEXT_WHITE), deactivated_on=deactivated_on or dict(color=TEXT_ON), deactivated_off=deactivated_off or dict(color=TEXT_OFF), *args, **kwargs) t.style(self, background=label_background, color=label_foreground, font=14)
def __init__(self, *args, **kwargs): """ normally you call self.make_title(text=...) after creation and call self.expand_me() later your place widgets onto self.backplate and add those into self.widgets = [], call self.set_position() manually if you're not resizing the widget wich would call it for you. :param args: :param kwargs: requires main, parent """ self.title = False self.crown = False self.old_position = False self.widgets = [] super().__init__(*args, **kwargs) self.make_toolplate() self.make_backplate() self.make_scrollarea() self.show() t.style(self, background=TRANSPARENT) t.style(self.backplate, background=TRANSPARENT)
def make_backplate(self): self.backplate = QtWidgets.QWidget(self) t.style(self.backplate, background=TRANSPARENT) t.pos(self.backplate, height=0) self.backplate.show()
def make_toolplate(self): self.toolplate = QtWidgets.QLabel(self) self.toolplate.widgets = [] t.style(self.toolplate, background=TRANSPARENT) self.toolplate.show()
def create_indikator(place, edge=1, button=False, lineedit=False, label=False, tiplabel=None, height=30, width=300, tipfont=None, tipwidth=None, tooltip=None, type=None, Special=None, share_signal=True, *args, **kwargs): if Special: canvas = Special(place=place, edge=edge, width=width, height=height, type=type, *args, **kwargs) else: canvas = Canvas(place=place, edge=edge, width=width, height=height, type=type, *args, **kwargs) if share_signal: kwargs['signal'] = canvas.signal kwargs['reset'] = False if lineedit: canvas.build_lineedit(**kwargs) if label: canvas.build_label(**kwargs) if button: canvas.build_button(**kwargs) if tiplabel: canvas.build_tiplabel(text=tiplabel, fontsize=tipfont, width=tipwidth) if tooltip: canvas.setToolTip(tooltip) t.style(canvas, tooltip=True, background='black', color='white', font=14) cycle = dict(lineedit='lineedit', label='label', button='button', tiplabel='tiplabel') cycle = {k: v for k, v in cycle.items() if k} for boolian, var in cycle.items(): tmp = [getattr(canvas, v) for k, v in cycle.items() if var != v] [ setattr(widget, var, getattr(canvas, var)) for widget in tmp if widget ] return canvas