Beispiel #1
0
	def __init__(self):
		QWidgetSavePos.__init__(self,"electrical")
		self.setFixedSize(1000, 600)
		self.setWindowIcon(QIcon_load("preferences-system"))

		self.setWindowTitle(_("Electrical parameter editor")+" (https://www.gpvdm.com)") 
		

		self.main_vbox = QVBoxLayout()

		toolbar=QToolBar()
		toolbar.setIconSize(QSize(48, 48))

		spacer = QWidget()
		spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
		toolbar.addWidget(spacer)


		self.undo = QAction(QIcon_load("help"), _("Help"), self)
		self.undo.setStatusTip(_("Help"))
		self.undo.triggered.connect(self.callback_help)
		toolbar.addAction(self.undo)

		self.main_vbox.addWidget(toolbar)

		self.notebook = QTabWidget()

		self.notebook.setMovable(True)

		self.main_vbox.addWidget(self.notebook)

		widget=tab_class()
		widget.init("device.inp",_("Device"))
		self.notebook.addTab(widget,_("Device"))

		widget=dos_main()
		widget.update()
		self.notebook.addTab(widget,_("Electrical parameters"))

		if enable_betafeatures()==True:
			widget=tab_bands()
			widget.update()
			self.notebook.addTab(widget,_("Complex DoS"))
		
		widget=pl_main()
		widget.update()
		self.notebook.addTab(widget,_("Luminescence"))



						
		self.setLayout(self.main_vbox)

		#self.connect("delete-event", self.callback_close_window) 
		self.notebook.currentChanged.connect(self.changed_click)
	def load(self):
		self.clean_menu()
		self.last_page=0
		#print "paths",os.getcwd(),get_bin_path(),(os.path.normcase(os.getcwd())!=os.path.normcase(get_bin_path()))
		if (os.path.exists("sim.opvdm")==True) and (os.path.normcase(os.getcwd())!=os.path.normcase(get_bin_path())):
			self.finished_loading=False
			self.progress.init()
			self.progress.show()
			self.progress.start()
			self.progress.set_text("Loading..")
			process_events()

			for child in self.get_children():
					self.remove(child)

			dos_files=inp_get_token_value("device_epitaxy.inp", "#layers")

			self.main_tab=tab_main()
			self.main_tab.init()
			self.main_tab.show()
			self.append_page(self.main_tab, gtk.Label(_("Device structure")))

			lines=[]
			pos=0
			if inp_load_file(lines,"gui_config.inp")==True:
				pos=0
				tab_number=0
				tabs=(len(lines)-3)/2
				print "tabs=",tabs
				while (1):
					add_to_widget=False
					ret,pos=inp_get_next_token_array(lines,pos)

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

					file_name=ret[0]
					if file_name[0]=="#":
						file_name=file_name[1:]
					name=inp_file_to_description(file_name)
					if name==False:
						print "name not found",name
						break
					visible=bool(int(ret[1]))

					self.progress.set_fraction(float(tab_number)/float(tabs))

					tab_number=tab_number+1
					self.progress.set_text(_("Loading ")+name)
					process_events()
					if file_name=="pl0.inp":
						tab=pl_main()
						tab.init()
						tab.update()
						add_to_widget=True
						tab.visible=visible
						tab.label_name=name
						tab.file_name=file_name
					elif file_name=="epitaxy.inp":
						tab=dos_main()
						tab.init()
						tab.update()
						add_to_widget=True
						tab.visible=visible
						tab.label_name=name
						tab.file_name=file_name
					elif file_name=="lumo0.inp":
						tab=tab_bands()
						tab.update()
						if tab.enabled==True:
							add_to_widget=True
							tab.visible=visible
							tab.wow()
							tab.label_name=name
							tab.file_name=file_name

					elif inp_isfile(file_name)==True:
						add_to_widget=True
						tab=tab_class()
						tab.visible=visible
						tab.init(file_name,name)
						tab.label_name=name
						tab.file_name=file_name

					if add_to_widget==True:
						#print file_name,name,visible,type(tab)
						hbox=gtk.HBox()
						hbox.set_size_request(-1, 25)
						mytext=name
						if len(mytext)<10:
							for i in range(len(mytext),10):
								mytext=mytext+" "

						label=gtk.Label(mytext)
						label.set_justify(gtk.JUSTIFY_LEFT)
						self.connect("switch-page", self.callback_switch_page)
						hbox.pack_start(label, False, True, 0)

						button = gtk.Button()
						close_image = gtk.Image()
						close_image.set_from_file(os.path.join(get_image_file_path(),"close.png"))
						print os.path.join(get_image_file_path(),"close.png")
						close_image.show()
						button = gtk.Button()
						button.add(close_image)


						button.props.relief = gtk.RELIEF_NONE
						button.connect("clicked", self.callback_close_button,name)
						button.set_size_request(25, 25)
						button.show()
					

						hbox.pack_end(button, False, False, 0)
						hbox.show_all()

						if (visible==True):
							tab.show()

						self.append_page(tab,hbox)



						self.set_tab_reorderable(tab,True)

						self.add_to_menu(name,visible)

			else:
				print _("No gui_config.inp file found\n")

			#for child in self.get_children():
			#		print type(child)

			if self.terminal_widget!=None:
				self.terminal_widget.show()
				self.append_page(self.terminal_widget, gtk.Label(_("Terminal")))


			self.add_welcome_page()

			self.finished_loading=True
			self.progress.stop()
			self.progress.set_fraction(0.0)
			self.goto_page("tab_main")

			self.set_tab_pos(gtk.POS_TOP)
			#self.set_current_page(1)

			return True
		else:
			self.add_welcome_page()
			self.goto_page(_("Welcome"))
			return False
	def load(self):
		self.clean_menu()
		self.last_page=0

		#self.setTabsClosable(True)
		self.setMovable(True)
		if (os.path.exists("sim.gpvdm")==True) and (os.path.normcase(os.getcwd())!=os.path.normcase(get_bin_path())):
			self.finished_loading=False
			#self.progress.init()
			#self.progress.show()
			#self.progress.start()
			#self.progress.set_text("Loading..")
			#process_events()

			self.clear()

#			dos_files=inp_get_token_value("device_epitaxy.inp", "#layers")

			widget=tab_main()

			self.addTab(widget,_("Device structure"))

	
			lines=[]
			pos=0
			if inp_load_file(lines,"gui_config.inp")==True:
				pos=0
				tab_number=0
				tabs=(len(lines)-3)/2
				while (1):
					add_to_widget=False
					ret,pos=inp_get_next_token_array(lines,pos)

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

					file_name=ret[0]
					if file_name[0]=="#":
						file_name=file_name[1:]
					name=inp_file_to_description(file_name)
					if name==False:
						print("name not found",name)
						break
					visible=bool(int(ret[1]))

					#self.progress.set_fraction(float(tab_number)/float(tabs))

					tab_number=tab_number+1
					#self.progress.set_text(_("Loading ")+name)
					#process_events()

					if file_name=="lumo0.inp":
						widget=tab_bands()
						#tab.update()
						add_to_widget=True
						widget.visible=visible
						widget.label_name=name
						widget.file_name=file_name
					elif file_name=="epitaxy.inp":
						widget=dos_main()
						widget.update()
						add_to_widget=True
						widget.visible=visible
						widget.label_name=name
						widget.file_name=file_name
					elif file_name=="pl0.inp":
						widget=pl_main()
						widget.update()
						add_to_widget=True
						widget.visible=visible
						widget.label_name=name
						widget.file_name=file_name
					elif inp_isfile(file_name)==True:
						add_to_widget=True
						widget=tab_class()
						widget.init(file_name,name)


					#	add_to_widget=True
					#	tab=
					#	tab.visible=visible
					#	tab.init(file_name,name)
					#	tab.label_name=name
					#	tab.file_name=file_name

					if add_to_widget==True:
						mytext=name
						if len(mytext)<10:
							for i in range(len(mytext),10):
								mytext=mytext+" "
						self.addTab(widget,mytext)


			self.terminal=tab_terminal()
			self.terminal.init()
			self.addTab(self.terminal,"Terminal")
			self.terminal.run(os.getcwd(),get_exe_command()+" --version --html")

			self.add_info_page()

			return True




			self.finished_loading=True
			#self.progress.stop()
			#self.progress.set_fraction(0.0)
			self.goto_page("tab_main")

		else:
			self.add_info_page()
			self.goto_page(_("Information"))
			return False