Ejemplo n.º 1
0
    def on_selection_changed(self):
        self.selected = []

        if len(self.selectedItems()) > 0:
            item = self.selectedItems()[0]
            if type(item) != None:
                obj = self.decode_name(item.text())
                if obj == None:
                    return

                file_name = obj.file_name

                self.file_path = os.path.join(self.path, file_name)

            for item in self.selectedItems():
                self.selected.append(self.decode_name(item.text()))

            full_path = self.file_path

            if (file_name.endswith(".dat") == True):
                state = dat_file()
                get_plot_file_info(state, full_path)
                summary = "<big><b>" + file_name + "</b></big><br><br>" + _(
                    "title") + ": " + state.title + "<br>" + _(
                        "x axis"
                    ) + ": " + state.y_label + " (" + latex_to_html(
                        state.y_units) + ")<br>" + _(
                            "y axis"
                        ) + ": " + state.data_label + " (" + latex_to_html(
                            state.data_units) + ")<br><br><big><b>" + _(
                                "Double click to open") + "</b></big>"
                help_window().help_set_help(["dat_file.png", summary])

            if file_name.endswith("equilibrium"):
                state = dat_file()
                get_plot_file_info(state, full_path)
                summary = "<big><b>" + _(
                    "equilibrium"
                ) + "</b></big><br><br>" + _(
                    "This contains the simulation output at 0V in the dark.")
                help_window().help_set_help(["folder.png", summary])

            #if os.path.isdir(full_path)==True:
            if get_dir_type(full_path) == "material":

                summary = "<b><big>" + file_name + "</b></big><br>"
                ref_path = os.path.join(full_path, "mat.bib")
                b = bibtex()

                if b.load(ref_path) != False:
                    summary = summary + b.get_text()
                help_window().help_set_help(["organic_material", summary])

        self.selection_changed.emit()
Ejemplo n.º 2
0
    def __init__(self):
        QScrollArea.__init__(self)
        self.vbox = QVBoxLayout()

        self.tab = QHBoxLayout()
        widget = QWidget()
        widget.setLayout(self.tab)
        self.file_path = os.path.join(get_user_settings_dir(), "lang.inp")

        title_label = QLabel()
        title_label.setWordWrap(True)
        title_label.setOpenExternalLinks(True)
        title_label.setText(
            latex_to_html(
                "<font size=5><b>Select the language you would like use gpvdm to use.</b><br><br> If a translation to your language does not exist or could be improved, then please consider joining the <a href=\"https://gpvdm.com/translation.html\">gpvdm translation project</a>.  I would like gpvdm translated into as many langauges as possible to improve access to high quality solar cell simulation tools for all.</font>"
            ))

        self.vbox.addWidget(title_label)
        self.vbox.addWidget(widget)

        description = QLabel()
        description.setText(latex_to_html("Default language:"))

        self.lang_box = QComboBox()

        self.lang_box.addItem("auto")

        self.lang_box.setFixedSize(300, 25)

        self.tab.addWidget(description)
        self.tab.addWidget(self.lang_box)

        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.vbox.addWidget(spacer)
        self.setLayout(self.vbox)

        langs = get_languages()
        if langs == False:
            return

        for i in range(0, len(langs)):
            self.lang_box.addItem(langs[i])

        token = inp_get_token_value(self.file_path, "#lang")
        all_items = [
            self.lang_box.itemText(i) for i in range(self.lang_box.count())
        ]
        for i in range(0, len(all_items)):
            if all_items[i] == token:
                self.lang_box.setCurrentIndex(i)

        self.lang_box.currentIndexChanged.connect(self.callback_edit)
Ejemplo n.º 3
0
    def on_selection_changed(self):
        if len(self.selectedItems()) > 0:
            item = self.selectedItems()[0]

            if type(item) != None:
                file_name = self.decode_name(item.text())
                if file_name == None:
                    return

                self.file_path = os.path.join(self.path, file_name)
            return

            if (file_name.endswith(".dat") == True):
                state = dat_file()
                get_plot_file_info(state, full_path)
                summary = "<big><b>" + file_name + "</b></big><br><br>" + _(
                    "title") + ": " + state.title + "<br>" + _(
                        "x axis"
                    ) + ": " + state.x_label + " (" + latex_to_html(
                        state.x_units) + ")<br>" + _(
                            "y axis"
                        ) + ": " + state.data_label + " (" + latex_to_html(
                            state.data_units) + ")<br><br><big><b>" + _(
                                "Double click to open") + "</b></big>"
                help_window().help_set_help(["dat_file.png", summary])

            if file_name.endswith("equilibrium"):
                state = dat_file()
                get_plot_file_info(state, full_path)
                summary = "<big><b>" + _(
                    "equilibrium"
                ) + "</b></big><br><br>" + _(
                    "This contains the simulation output at 0V in the dark.")
                help_window().help_set_help(["folder.png", summary])

            if os.path.isdir(full_path) == True:
                if os.path.isfile(os.path.join(full_path, "mat.inp")):
                    summary = "<b><big>" + file_name + "</b></big><br>"
                    ref_path = os.path.join(full_path, "n.ref")
                    ref = get_ref_text(ref_path)
                    if ref != None:
                        summary = summary + ref
                    help_window().help_set_help(["organic_material", summary])
Ejemplo n.º 4
0
	def populate(self,lines):

		self.f.lines=lines
		n=0
		pos=0
		my_token_lib=tokens()
		widget_number=0
		bib=bibtex()
		if self.file_name!=None:
			bib.load(os.path.splitext(self.file_name)[0]+".bib")
		while (1):
			token,values=self.f.get_next_token_array()
			if token=="#ver":
				break

			if token=="#end":
				break

			if token.startswith("#"):
				show=False
				units="Units"

				value=values[0]

				result=my_token_lib.find(token)
				if result!=False:
					#print(token,result.info)
					units=result.units
					text_info=result.info
					show=True
					if result.hidden==True:
						show=False
				
				if show == True :
					description=QLabel_click()
					description.setText(latex_to_html(text_info))
					if self.file_name!=None:
						if bib.get_ref(token)!=False:
							description.setStyleSheet('color: green')
						description.clicked.connect(functools.partial(self.callback_ref,token,description))

					#units widget
					if result.units_widget=="QLabel":
						unit=QLabel()
						unit.setText(latex_to_html(units))
					elif result.units_widget=="QPushButton":
						unit=QPushButton()
						unit.setText(latex_to_html(units))
						unit.setFixedSize(50, 25)

					#edit widget
					if result.widget=="gtkswitch":
						edit_box=gtkswitch()
						edit_box.setFixedSize(300, 25)
						edit_box.changed.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))
					elif result.widget=="leftright":
						edit_box=leftright()
						edit_box.setFixedSize(300, 25)
						edit_box.changed.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))
					elif result.widget=="gpvdm_select":
						edit_box=gpvdm_select(file_box=True)
						edit_box.setFixedSize(300, 25)
						edit_box.edit.textChanged.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))
					elif result.widget=="gpvdm_select_material":
						edit_box=gpvdm_select_material(file_box=False)
						edit_box.setFixedSize(300, 25)
						edit_box.edit.textChanged.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))

					elif result.widget=="gpvdm_select_emission":
						edit_box=gpvdm_select_emission(file_box=False)
						edit_box.setFixedSize(300, 25)
						edit_box.edit.textChanged.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))

					elif result.widget=="QLineEdit":
						edit_box=QLineEdit()
						edit_box.setFixedSize(300, 25)
						if self.editable==False:
							edit_box.setReadOnly(True)

						edit_box.textChanged.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))
						#edit_box.show()
					elif result.widget=="QColorPicker":
						r=float(values[0])
						g=float(values[1])
						b=float(values[2])
						edit_box=QColorPicker(r,g,b)
						edit_box.setFixedSize(300, 25)
						edit_box.changed.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))
					elif result.widget=="QComboBoxLang":
						edit_box=QComboBoxLang()
						edit_box.setFixedSize(300, 25)
						for i in range(0,len(result.defaults)):
							edit_box.addItemLang(result.defaults[i][0],result.defaults[i][1])
								
						edit_box.currentIndexChanged.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))
					elif result.widget=="QComboBoxNewtonSelect":
						edit_box=QComboBoxNewtonSelect()
						edit_box.setFixedSize(300, 25)
						for i in range(0,len(result.defaults)):
							edit_box.addItem(result.defaults[i])

						edit_box.currentIndexChanged.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))
					elif result.widget=="QComboBoxShape":
						edit_box=QComboBoxShape()
						edit_box.setFixedSize(300, 25)
						edit_box.currentIndexChanged.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))

					elif result.widget=="QParasitic":
						edit_box=QParasitic()
						edit_box.setFixedSize(300, 25)
						edit_box.textChanged.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))

					elif result.widget=="QChangeLog":
						edit_box=QChangeLog(self)
						edit_box.setMinimumHeight(100)
						if self.editable==False:
							edit_box.setReadOnly(True)
						edit_box.textChanged.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))
					elif result.widget=="generic_switch":
						edit_box=generic_switch(state0=result.defaults[0][0],state1=result.defaults[1][0],state0_value=result.defaults[0][1],state1_value=result.defaults[1][1],)
						edit_box.setFixedSize(300, 25)
						if value=="exponential":
							unit.setEnabled(False)
						edit_box.changed.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))
					elif result.widget=="mobility_widget":
						edit_box=mobility_widget(electrons=result.defaults[0])
						edit_box.setFixedSize(400, 25)
						if token=="#symmetric_mobility_e":
							value = [self.f.get_token(token),self.f.get_token("#mue_z"),self.f.get_token("#mue_x"),self.f.get_token("#mue_y")]
						if token=="#symmetric_mobility_h":
							value = [self.f.get_token(token),self.f.get_token("#muh_z"),self.f.get_token("#muh_x"),self.f.get_token("#muh_y")]
						if token=="#electrical_symmetrical_resistance":
							value = [self.f.get_token(token),self.f.get_token("#electrical_series_z"),self.f.get_token("#electrical_series_x"),self.f.get_token("#electrical_series_y")]

						edit_box.changed.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))
					elif result.widget=="shape_dos_switch":
						edit_box=shape_dos_switch()
						edit_box.shape_file=self.file_name
						edit_box.setFixedSize(300, 25)
						edit_box.changed.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))
						if value=="none":
							unit.setEnabled(False)

					else:
						edit_box=QComboBox()
						edit_box.setFixedSize(300, 25)
						for i in range(0,len(result.defaults)):
							edit_box.addItem(result.defaults[i])
						
						edit_box.currentIndexChanged.connect(functools.partial(self.callback_edit,token,edit_box,unit,result))

					widget_set_value(edit_box,value)

					if type(unit)==QPushButton:
						unit.clicked.connect(functools.partial(self.callback_unit_click,token,edit_box,unit))

					a=tab_line()
					a.token=token
					a.label=description
					a.edit_box=edit_box
					a.units=unit
					a.widget=result.widget
					a.hide_on_true_token=result.hide_on_true_token
					a.hide_on_false_token=result.hide_on_false_token
					a.hide_on_token_eq=result.hide_on_token_eq

					self.widget_list.append(a)
					self.tab.addWidget(description,widget_number,0)
					self.tab.addWidget(edit_box,widget_number,1)
					self.tab.addWidget(unit,widget_number,2)
										
					widget_number=widget_number+1

		self.hide_show_widgets()
Ejemplo n.º 5
0
    def init(self, filename, tab_name):
        self.scroll = QScrollArea()
        self.main_box_widget = QWidget()
        self.vbox = QVBoxLayout()
        self.hbox = QHBoxLayout()
        self.hbox.setAlignment(Qt.AlignTop)
        self.file_name = filename
        self.tab_name = tab_name

        self.tab = QGridLayout()
        widget = QWidget()
        widget.setLayout(self.tab)
        self.vbox.addWidget(widget)

        scan_remove_file(filename)

        self.edit_list = []
        self.lines = inp_load_file(filename)
        if self.lines == False:
            error_dlg(self, _("File not found.") + " " + filename)
            return
        n = 0
        pos = 0
        my_token_lib = tokens()
        widget_number = 0

        while (1):
            ret, pos = inp_get_next_token_array(self.lines, pos)

            token = ret[0]
            if token == "#ver":
                break

            if token == "#end":
                break

            if token.startswith("#"):
                show = False
                units = "Units"

                value = ret[1]

                result = my_token_lib.find(token)
                if result != False:
                    units = result.units
                    text_info = result.info
                    show = True

                #self.set_size_request(600,-1)
                if show == True:
                    description = QLabel_click()
                    description.setText(latex_to_html(text_info))
                    if os.path.isfile(
                            os.path.splitext(filename)[0] + "_" + token[1:] +
                            ".ref"):
                        description.setStyleSheet('color: green')

                    description.clicked.connect(
                        functools.partial(self.callback_ref, filename, token,
                                          description))

                    if result.widget == "gtkswitch":
                        edit_box = gtkswitch()
                        edit_box.setFixedSize(300, 25)
                        edit_box.set_value(str2bool(value))
                        edit_box.changed.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                    elif result.widget == "leftright":
                        edit_box = leftright()
                        edit_box.setFixedSize(300, 25)
                        edit_box.set_value(str2bool(value))
                        edit_box.changed.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                    elif result.widget == "gpvdm_select":
                        edit_box = gpvdm_select(file_box=True)
                        edit_box.setFixedSize(300, 25)
                        edit_box.setText(value)
                        edit_box.edit.textChanged.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                    elif result.widget == "QLineEdit":
                        edit_box = QLineEdit()
                        edit_box.setFixedSize(300, 25)
                        if self.editable == False:
                            edit_box.setReadOnly(True)
                        edit_box.setText(value)
                        #edit_box.set_text(self.lines[pos]);
                        edit_box.textChanged.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                        #edit_box.show()
                    elif result.widget == "QColorPicker":
                        r = float(ret[1])
                        g = float(ret[2])
                        b = float(ret[3])
                        edit_box = QColorPicker(r, g, b)
                        edit_box.setFixedSize(300, 25)
                        edit_box.changed.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                    elif result.widget == "QComboBoxLang":
                        edit_box = QComboBoxLang()
                        edit_box.setFixedSize(300, 25)
                        for i in range(0, len(result.defaults)):
                            edit_box.addItemLang(result.defaults[i][0],
                                                 result.defaults[i][1])

                        edit_box.setValue_using_english(value)

                        edit_box.currentIndexChanged.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                    elif result.widget == "QParasitic":
                        edit_box = QParasitic()
                        edit_box.setFixedSize(300, 25)
                        edit_box.setValue(value)
                        edit_box.textChanged.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))

                    elif result.widget == "QChangeLog":
                        edit_box = QChangeLog()
                        edit_box.setMinimumHeight(100)
                        if self.editable == False:
                            edit_box.setReadOnly(True)
                        edit_box.setText(value)
                        edit_box.textChanged.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))
                    else:
                        edit_box = QComboBox()
                        edit_box.setFixedSize(300, 25)
                        for i in range(0, len(result.defaults)):
                            edit_box.addItem(result.defaults[i])

                        all_items = [
                            edit_box.itemText(i)
                            for i in range(edit_box.count())
                        ]
                        for i in range(0, len(all_items)):
                            if all_items[i] == value:
                                edit_box.setCurrentIndex(i)
                                break

                        edit_box.currentIndexChanged.connect(
                            functools.partial(self.callback_edit, filename,
                                              token, edit_box))

                    unit = QLabel()
                    unit.setText(latex_to_html(units))

                    self.tab.addWidget(description, widget_number, 0)
                    self.tab.addWidget(edit_box, widget_number, 1)
                    self.tab.addWidget(unit, widget_number, 2)

                    scan_item_add(filename, token, text_info, 1)

                    widget_number = widget_number + 1

        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.vbox.addWidget(spacer)
        self.main_box_widget.setLayout(self.vbox)

        self.scroll.setWidget(self.main_box_widget)

        self.icon_widget = QWidget()
        self.icon_widget_vbox = QVBoxLayout()
        self.icon_widget.setLayout(self.icon_widget_vbox)

        if self.icon_file != "":
            self.image = QLabel()
            icon = QIcon_load(self.icon_file)
            self.image.setPixmap(icon.pixmap(icon.actualSize(QSize(32, 32))))
            self.icon_widget_vbox.addWidget(self.image)

            spacer2 = QWidget()
            spacer2.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
            self.icon_widget_vbox.addWidget(spacer2)

            self.hbox.addWidget(self.icon_widget)

        self.hbox.addWidget(self.scroll)

        self.setLayout(self.hbox)
Ejemplo n.º 6
0
	def on_selection_changed(self,item):
		if type(item)!=None:
			file_name=item.text()
			print(file_name)
			full_path=os.path.join(self.dir, file_name)
			if (file_name.endswith(".dat")==True):
				state=plot_state()
				get_plot_file_info(state,full_path)
				summary="<big><b>"+file_name+"</b></big><br>"+_("<br>title: ")+state.title+_("<br>x axis: ")+state.x_label+" ("+latex_to_html(state.x_units)+_(")<br>y axis: ")+state.y_label+" ("+latex_to_html(state.y_units)+_(")<br><br><big><b>Double click to open</b></big>")
				help_window().help_set_help(["dat_file.png",summary])

			if file_name.endswith("equilibrium"):
				state=plot_state()
				get_plot_file_info(state,full_path)
				summary="<big><b>equilibrium</b></big><br>"+_("<br>This contains the simulation output at 0V in the dark.")
				help_window().help_set_help(["dir_file.png",summary])
Ejemplo n.º 7
0
    def init(self, filename, tab_name):
        self.vbox = QVBoxLayout()
        self.file_name = filename
        self.tab_name = tab_name

        self.tab = QGridLayout()
        widget = QWidget()
        widget.setLayout(self.tab)
        self.vbox.addWidget(widget)

        scan_remove_file(filename)

        self.edit_list = []
        inp_load_file(self.lines, filename)

        n = 0
        pos = 0
        my_token_lib = tokens()
        height = 27
        widget_number = 0
        while pos < len(self.lines):
            token = self.lines[pos]
            if token == "#ver":
                break

            if token == "#end":
                break

            if token.startswith("#"):
                show = False
                units = "Units"

                pos = pos + 1
                value = self.lines[pos]

                result = my_token_lib.find(token)
                if result != False:
                    units = result.units
                    text_info = result.info
                    show = True

                    # self.set_size_request(600,-1)
                if show == True:
                    description = QLabel()
                    description.setText(latex_to_html(text_info))

                    if result.opt[0] == "switch":
                        edit_box = gtkswitch()
                        edit_box.set_value(str2bool(value))
                        edit_box.changed.connect(functools.partial(self.callback_edit, filename, token, edit_box))
                    elif result.opt[0] == "leftright":
                        edit_box = leftright()
                        edit_box.set_value(str2bool(value))
                        edit_box.changed.connect(functools.partial(self.callback_edit, filename, token, edit_box))
                    elif result.opt[0] == "text":
                        edit_box = QLineEdit()
                        if self.editable == False:
                            edit_box.setReadOnly(True)
                        edit_box.setText(value)
                        # edit_box.set_text(self.lines[pos]);
                        edit_box.textChanged.connect(functools.partial(self.callback_edit, filename, token, edit_box))
                        # edit_box.show()
                    else:
                        edit_box = QComboBox()
                        for i in range(0, len(result.opt)):
                            edit_box.addItem(result.opt[i])

                        all_items = [edit_box.itemText(i) for i in range(edit_box.count())]
                        for i in range(0, len(all_items)):
                            if all_items[i] == token:
                                edit_box.setCurrentIndex(i)

                        edit_box.currentIndexChanged.connect(
                            functools.partial(self.callback_edit, filename, token, edit_box)
                        )

                    edit_box.setFixedSize(300, 25)
                    unit = QLabel()
                    unit.setText(latex_to_html(units))

                    self.tab.addWidget(description, widget_number, 0)
                    self.tab.addWidget(edit_box, widget_number, 1)
                    self.tab.addWidget(unit, widget_number, 2)

                    scan_item_add(filename, token, text_info, 1)

                    widget_number = widget_number + 1
            pos = pos + 1

        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.vbox.addWidget(spacer)

        self.setLayout(self.vbox)