Example #1
0
	def callback_plot_select(self):
		help_window().help_set_help(["dat_file.png",_("<big>Select a file to plot</big><br>Single clicking shows you the content of the file")])

		dialog=gpvdm_open(os.getcwd())
		dialog.show_inp_files=False
		dialog.show_directories=False
		ret=dialog.window.exec_()
		if ret==QDialog.Accepted:
			split=dialog.get_filename().split(".")
			if len(split)>1:
				if split[1]=="xlsx" or split[1]=="xls":
					desktop_open(dialog.get_filename())
	
					print("open with excel")
					return
				
			if os.path.basename(dialog.get_filename())=="sim_info.dat":
				if self.sim_info_window==None:
					self.sim_info_window=sim_info(dialog.get_filename())

				if self.sim_info_window.isVisible()==True:
					self.sim_info_window.hide()
				else:
					self.sim_info_window.show()
				return

			plot_gen([dialog.get_filename()],[],"auto")
Example #2
0
	def callback_dir_open(self):
		dialog=gpvdm_open(self.path)
		dialog.show_inp_files=False
		ret=dialog.exec_()

		if ret==QDialog.Accepted:
			desktop_open(dialog.get_filename())
Example #3
0
    def on_item_activated(self, item):
        text = item.text()
        if text == "..":
            self.set_path(os.path.dirname(self.path))
            self.fill_store()
            return

        decode = self.decode_name(text)
        if self.decode_name(text).startswith("http"):
            webbrowser.open(decode)
            return

        full_path = os.path.join(self.path, decode)

        if os.path.isfile(full_path) == True:
            self.file_path = full_path
            if self.open_own_files == True:
                if isfiletype(full_path, "xls") == True or isfiletype(
                        full_path, "xlsx") == True or isfiletype(
                            full_path, "pdf") == True:
                    desktop_open(full_path)
                    self.reject.emit()
                    return
                elif isfiletype(full_path, "jpg") == True:
                    desktop_open(full_path)
                    self.reject.emit()
                    return
                elif os.path.basename(full_path) == "sim_info.dat":
                    self.sim_info_window = sim_info(full_path)
                    self.sim_info_window.show()
                    self.reject.emit()
                    return
                elif isfiletype(full_path, "dat") == True:
                    plot_gen([full_path], [], "auto")
                    self.reject.emit()
                    return
            else:
                self.accept.emit()
                return
        else:
            if os.path.isfile(os.path.join(full_path, "mat.inp")) == True:
                self.file_path = full_path

                gpvdm_file_type = inp_get_token_value(
                    os.path.join(full_path, "mat.inp"), "#gpvdm_file_type")
                if gpvdm_file_type == "spectra":
                    from spectra_main import spectra_main
                    self.mat_window = spectra_main(full_path)
                    self.mat_window.show()
                elif gpvdm_file_type == "mat":
                    from materials_main import materials_main
                    self.mat_window = materials_main(full_path)
                    self.mat_window.show()

                self.accept.emit()
            else:
                self.set_path(full_path)
                #self.path = full_path
                self.fill_store()
Example #4
0
    def callback_notes(self):
        notes_path = os.path.join(self.sim_dir, "notes.txt")
        if os.path.isfile(notes_path) == False:
            out = open(notes_path, 'w')
            out.write("Notes on the simulation: " +
                      os.path.basenam(self.sim_dir) + "\n")
            out.write("Date: " +
                      datetime.datetime.today().strftime('%Y-%m-%d') + "\n")
            out.write("Generated by: " + os.getusername() + "\n")
            out.write("\n")
            out.close()
        else:
            out = open(notes_path, 'a')
            out.write("\n" + datetime.datetime.today().strftime('%Y-%m-%d') +
                      ":\n")
            out.close()

        desktop_open(notes_path)
Example #5
0
	def callback_cost(self):
		desktop_open(os.path.join(self.path,"cost.xlsx"))
Example #6
0
	def on_item_activated(self,item):
		text=item.text()
		if text=="..":
			if self.path==self.root_dir:
				self.set_path("/gpvdmroot")
			else:
				old_path=self.path
				self.set_path(os.path.dirname(self.path))
				print(self.path,old_path,os.path.dirname(self.path))
				if old_path==self.path:
					self.set_path("/gpvdmroot")
			self.fill_store()
			return

		decode=self.decode_name(text)
		if decode.startswith("http"):
			webbrowser.open(decode)
			return
		elif decode=="home_dir":
			self.set_path(get_home_path())
			self.fill_store()
			return
		elif decode=="desktop_dir":
			self.set_path(get_desktop_path())
			self.fill_store()
			return
		elif decode=="gpvdm_configure":
			self.set_path("/gpvdmroot/gpvdm_configure")
			self.fill_store()
			return

		elif decode=="music_dir":
			self.set_path(get_music_path())
			self.fill_store()
			return
		elif decode=="downloads_dir":
			self.set_path(get_downloads_path())
			self.fill_store()
			return
		elif decode=="simulation_dir":
			self.set_path(get_sim_path())
			self.fill_store()
			return			
		elif decode.startswith("mount_point")==True:
			point=decode.split("::::")
			self.set_path(point[1])
			self.fill_store()
			return
		elif decode=="gpvdm_cluster_config":
			self.win=cluster_config_window(self)
			self.win.show()
			return
		elif decode=="gpvdm_language_config":
			self.config_window=class_config_window()

			from tab_lang import language_tab_class

			self.config_window.files=[ ]
			self.config_window.description=[]
			self.config_window.init()
			lang_tab=language_tab_class()
			self.config_window.notebook.addTab(lang_tab,_("Language"))
			self.config_window.show()

			return
		elif decode=="gpvdm_solver_config":
			self.config_window=class_config_window()
			self.config_window.files=["math.inp"]
			self.config_window.description=[_("Solver configuration")]
			self.config_window.init()
			self.config_window.show()

			return
		elif decode=="gpvdm_led_config":
			self.config_window=class_config_window()
			self.config_window.files=["led.inp"]
			self.config_window.description=[_("LED")]
			self.config_window.init()
			self.config_window.show()
			return
		elif decode=="gpvdm_dump_config":
			self.config_window=class_config_window()
			self.config_window.files=["dump.inp"]
			self.config_window.description=[_("Output files")]
			self.config_window.init()
			self.config_window.show()
			return
		elif decode=="gpvdm_gui_config":
			self.config_window=class_config_window()
			self.config_window.files=["config.inp"]
			self.config_window.description=[_("GUI configuration"),]
			self.config_window.init()
			self.config_window.show()
			return
		elif decode=="gpvdm_thermal_config":
			self.config_window=class_config_window()
			self.config_window.files=["thermal.inp"]
			self.config_window.description=[_("Thermal")]
			self.config_window.init()
			self.config_window.show()
			return
		elif decode=="gpvdm_server_config":
			self.config_window=class_config_window()
			self.config_window.files=["server.inp"]
			self.config_window.description=[_("Server configuration")]
			self.config_window.init()
			self.config_window.show()
			return


		full_path=os.path.join(self.path,decode)
		if is_mat_file(full_path)==True:
			print("mat file!!")
			from materials_main import materials_main
			self.mat_window=materials_main(full_path)
			self.mat_window.show()
			return


		if os.path.isfile(full_path)==True:
			self.file_path=full_path
			if self.open_own_files==True:
				if os.path.basename(full_path)=="sim_info.dat":
					self.sim_info_window=sim_info(full_path)
					self.sim_info_window.show()
					self.reject.emit()
					return
				elif isfiletype(full_path,"dat")==True:
					plot_gen([full_path],[],"auto")
					self.reject.emit()
					return

				else:
					desktop_open(full_path)
					self.reject.emit()
					return

#				else:
#					self.accept.emit()	
			else:
				self.accept.emit()
				return
		else:
			if os.path.isfile(os.path.join(full_path,"mat.inp"))==True:
				self.file_path=full_path

				gpvdm_file_type=inp_get_token_value(os.path.join(full_path,"mat.inp"), "#gpvdm_file_type")
				if gpvdm_file_type=="spectra":
					from spectra_main import spectra_main
					self.mat_window=spectra_main(full_path)
					self.mat_window.show()

				self.accept.emit()
			else:
				self.set_path(full_path)
				#self.path = full_path
				self.fill_store()
Example #7
0
    def on_item_activated(self, item):
        text = item.text()
        if text == "..":
            if self.path == self.root_dir:
                self.set_path("/gpvdmroot")
            else:
                old_path = self.path
                self.set_path(os.path.dirname(self.path))
                #print(self.path,old_path,os.path.dirname(self.path))
                if old_path == self.path:
                    self.set_path("/gpvdmroot")
            self.fill_store()
            return

        decode = self.decode_name(text)
        full_path = os.path.join(self.path, decode.file_name)

        if decode.file_name.startswith("http"):
            webbrowser.open(decode)
            return
        elif decode.file_name == "home_dir":
            self.set_path(get_home_path())
            self.fill_store()
            return
        elif decode.file_name == "desktop_dir":
            self.set_path(get_desktop_path())
            self.fill_store()
            return
        elif decode.file_name == "gpvdm_configure":
            self.set_path("/gpvdmroot/gpvdm_configure")
            self.fill_store()
            return

        elif decode.file_name == "music_dir":
            self.set_path(get_music_path())
            self.fill_store()
            return
        elif decode.file_name == "downloads_dir":
            self.set_path(get_downloads_path())
            self.fill_store()
            return
        elif decode.file_name == "simulation_dir":
            self.set_path(get_sim_path())
            self.fill_store()
            return
        elif decode.file_name.startswith("mount_point") == True:
            point = decode.split("::::")
            self.set_path(point[1])
            self.fill_store()
            return
        elif decode == "gpvdm_cluster_config":
            self.win = cluster_config_window(self)
            self.win.show()
            return
        elif decode.file_name == "gpvdm_language_config":
            self.config_window = class_config_window()

            from tab_lang import language_tab_class

            self.config_window.files = []
            self.config_window.description = []
            self.config_window.init()
            lang_tab = language_tab_class()
            self.config_window.notebook.addTab(lang_tab, _("Language"))
            self.config_window.show()

            return
        elif decode.file_name == "gpvdm_solver_config":
            self.config_window = class_config_window()
            self.config_window.files = ["math.inp"]
            self.config_window.description = [_("Solver configuration")]
            self.config_window.init()
            self.config_window.show()

            return

        elif decode.file_name == "gpvdm_dump_config":
            self.config_window = class_config_window()
            self.config_window.files = ["dump.inp"]
            self.config_window.description = [_("Output files")]
            self.config_window.init()
            self.config_window.show()
            return
        elif decode.file_name == "gpvdm_gui_config":
            self.config_window = class_config_window()
            self.config_window.files = ["config.inp"]
            self.config_window.description = [
                _("GUI configuration"),
            ]
            self.config_window.init()
            self.config_window.show()
            return
        elif decode.file_name == "gpvdm_server_config":
            self.config_window = class_config_window()
            self.config_window.files = ["server.inp"]
            self.config_window.description = [_("Server configuration")]
            self.config_window.init()
            self.config_window.show()
            return
        elif decode.file_name == "gpvdm_key":
            from lock_key_manager import lock_key_manager
            from msg_dlg import msg_dlg
            self.lock_key_manager = lock_key_manager(
                show_text=False,
                override_text=_("Please enter your license key:"))
            ret = self.lock_key_manager.run()
            if ret == QDialog.Accepted:
                msgBox = msg_dlg()
                msgBox.setText("License updated")
                reply = msgBox.exec_()
        elif decode.file_name == "gpvdm_cache":
            from cache import cache
            self.c = cache()
            self.c.show()
        elif decode.type == "scan_dir":
            from scan_tab import scan_vbox
            #print(full_path)
            self.scan_window = scan_vbox(full_path)
            self.scan_window.show()
            return
        elif decode.type == "parameter_dir":
            self.set_path(full_path)
            self.fill_store()
            return
        dir_type = get_dir_type(full_path)

        if self.open_own_files == True:
            self.file_path = full_path

            if dir_type == "spectra":
                from spectra_main import spectra_main
                self.mat_window = spectra_main(full_path)
                self.mat_window.show()
                return
            if dir_type == "shape":
                from shape_editor import shape_editor
                self.windows.append(shape_editor(full_path))
                self.windows[-1].show()
                return
            if dir_type == "light":
                from optics import class_optical
                self.optics_window = class_optical()
                self.optics_window.show()

            if dir_type == "material":
                from materials_main import materials_main
                self.mat_window = materials_main(full_path)
                self.mat_window.show()
                return

            if dir_type == "emission":
                from emission_main import emission_main
                self.emission_window = emission_main(full_path)
                self.emission_window.show()
                return

            if dir_type == "snapshots":
                from cmp_class import cmp_class

                help_window().help_set_help([
                    "plot_time.png",
                    _("<big><b>Examine the results in time domain</b></big><br> After you have run a simulation in time domain, if is often nice to be able to step through the simulation and look at the results.  This is what this window does.  Use the slider bar to move through the simulation.  When you are simulating a JV curve, the slider sill step through voltage points rather than time points."
                      )
                ])

                self.snapshot_window.append(cmp_class(full_path))
                self.snapshot_window[-1].show()
                #print("snapshots!!")
                return

            if dir_type == "backup":
                ret = yes_no_dlg(
                    self,
                    _("Are you sure you want restore this file from the backup, it will overwrite all files in the simulation directory?"
                      ) + "\n\n" + full_path)
                if ret == True:
                    from backup import backup_restore
                    backup_restore(get_sim_path(), full_path)

            if dir_type == "file":
                self.file_path = full_path
                if os.path.basename(full_path) == "sim_info.dat":
                    self.sim_info_window = sim_info(full_path)
                    self.sim_info_window.show()
                    return

                if isfiletype(full_path, "dat") == True:
                    text = peek_data(full_path)
                    if text.startswith(b"#multiplot"):
                        my_multiplot = multiplot()
                        my_multiplot.plot(full_path)
                    else:
                        plot_gen([full_path], [], "auto")
                    return

                if isfiletype(full_path, "gpvdm") == True:
                    return

                desktop_open(full_path)
                return
#self.reject.emit()

        if dir_type == "dir" or dir_type == "backup_main" or dir_type == "multi_plot_dir":
            self.file_path = full_path
            self.set_path(full_path)
            self.fill_store()
        else:
            self.accept.emit()
	def callback_cost(self):
		desktop_open(os.path.join(self.path,"cost.xlsx"))