def __init__(self, img_name, header, questions): super().__init__() img = QPixmap(img_name) img_holder = qtw.QLabel() img_holder.setPixmap(img.scaled(800, 500, Qt.KeepAspectRatio, Qt.SmoothTransformation)) img_holder.setAlignment(Qt.AlignCenter) self.question = MultiQuestion(header, questions) layout = qtw.QVBoxLayout() layout.addWidget(img_holder) layout.addWidget(self.question) self.setLayout(layout)
def __init__(self, brand, subprompt, warm, friendly, rest_header, rest_qs): super().__init__() self.warm_q = SingleQuestion(*warm) self.friendly_q = SingleQuestion(*friendly) # One MultiQuestion (same header) self.multi_q = MultiQuestion(rest_header, rest_qs) txt = JustText(subprompt % brand) # Please answer the following... lt = qtw.QVBoxLayout() lt.addWidget(txt) lt.addWidget(self.warm_q) lt.addWidget(self.friendly_q) lt.addWidget(self.multi_q) self.setLayout(lt)
def __init__(self, block_num, device, temperature, settings): super().__init__(block_num, device, temperature, settings) lang = settings['language'] translation_path = os.path.join(settings['translation_dir'], '%s.toml' % self.name) with open(translation_path, 'r', encoding='utf8') as f: translation = toml.load(f) prompt = translation['prompt'][lang] header = translation['header'][lang] self.questions = [('q%i' % i, q[lang]) for i, q in enumerate(translation['question'])] random.shuffle(self.questions) layout = qtw.QVBoxLayout() self.qs = MultiQuestion(header, [q[1] for q in self.questions]) head = qtw.QLabel(prompt) head.setStyleSheet('font-size:26pt;') head.setWordWrap(True) layout.addWidget(head) layout.addWidget(self.qs) self.setLayout(layout)
def __init__(self, block_num, device, temperature, settings): super().__init__(block_num, device, temperature, settings) lang = settings['language'] locale = settings['locale'] translation_path = os.path.join(settings['translation_dir'], '%s.toml' % self.name) with open(translation_path, 'r', encoding='utf8') as f: translation = toml.load(f) locale_path = os.path.join(settings['locale_dir'], '%s.toml' % self.name) with open(locale_path, 'r', encoding='utf8') as f: locale_settings = toml.load(f) # read in all images try: images = locale_settings['house_photos'][locale] except KeyError: # use default locale (US) images = locale_settings['house_photos']['us'] # now handle localized image location for count, img in enumerate(images): # if locale has path specified, look relative to exe location if os.path.split(img)[0] != '': # TODO: verify this is the right pattern images[count] = os.path.join(application_path, img) else: # no path for locale, assume it's one of the baked-in ones images[count] = resource_filename('embr_survey', 'images/%s' % img) # read in translations, also plugging in locale-specific info self.prompt = translation['prompt'][lang] self.preprompt = translation['preprompt'][lang] self.big_title = translation['big_title'][lang] try: cost = locale_settings['house_cost'][locale] except KeyError: cost = locale_settings['house_cost']['us'] self.background = translation['background'][lang] % cost self.subtitle = translation['subtitle'][lang] self.floor1 = translation['f1'][lang] try: floor_label = locale_settings['floor_label'][locale] except KeyError: floor_label = locale_settings['floor_label']['us'] self.floor2 = translation['f2'][lang] % floor_label[0] self.floor3 = translation['f3'][lang] % floor_label[1] prompt2 = translation['prompt2'][lang] header = translation['header'][lang] self.questions = [('q%i' % i, q[lang]) for i, q in enumerate(translation['question'])] random.shuffle(self.questions) # now set up gui self.images = {os.path.basename(n): QPixmap(n) for n in images} for img in self.images: ql = qtw.QLabel() ql.setPixmap(self.images[img].scaled(800, 500, Qt.KeepAspectRatio, Qt.SmoothTransformation)) self.images[img] = ql layout = qtw.QVBoxLayout() layout.addWidget(JustText( self.prompt)) # next, we are going to present... layout.addWidget(JustText(self.preprompt)) # what do you think.. layout.addWidget(self.images['dv5_1.png'], alignment=Qt.AlignCenter) # initial image layout.addWidget(JustText('<b>%s</b>' % self.big_title)) # general info layout.addWidget(JustText(self.background)) # General info... layout.addWidget(JustText(self.subtitle)) # the resale value... layout.addWidget(JustText(self.floor1)) layout.addWidget(JustText(self.floor2)) layout.addWidget(JustText(self.floor3)) imgs = [('dv5_2.png', 'dv5_3.png'), ('dv5_4.png', 'dv5_5.png'), ('dv5_6.png', 'dv5_7.png'), ('dv5_8.png', 'dv5_9.png')] for im1, im2 in imgs: r1 = qtw.QHBoxLayout() r1.addWidget(self.images[im1]) r1.addWidget(self.images[im2]) w1 = qtw.QWidget() w1.setLayout(r1) layout.addWidget(w1, alignment=Qt.AlignCenter) layout.addWidget(self.images['dv5_10.png'], alignment=Qt.AlignCenter) layout.addWidget(JustText(prompt2)) self.qs = MultiQuestion(header, [q[1] for q in self.questions]) layout.addWidget(self.qs) self.setLayout(layout)