Example #1
0
	def init(self,myserver,tooltips,status_bar,context_id,tab_label,scan_root_dir,sim_name):

		self.tokens=tokens()
		self.config=config()
		self.sim_name=sim_name
		self.clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
		self.popup_menu = gtk.Menu()

		menu_item = gtk.MenuItem(_("Select parameter to scan"))
		menu_item.connect("activate", self.callback_show_list)
		self.popup_menu.append(menu_item)
		self.popup_menu.show_all()

		menu_item = gtk.SeparatorMenuItem()
		self.popup_menu.append(menu_item)
		self.popup_menu.show_all()

		menu_item = gtk.MenuItem(_("Delete item"))
		menu_item.connect("activate", self.callback_delete_item)
		self.popup_menu.append(menu_item)
		self.popup_menu.show_all()

		menu_item = gtk.MenuItem(_("Add item"))
		menu_item.connect("activate", self.callback_add_item)
		self.popup_menu.append(menu_item)
		self.popup_menu.show_all()

		menu_item = gtk.MenuItem(_("Move down"))
		menu_item.connect("activate", self.callback_move_down)
		self.popup_menu.append(menu_item)
		self.popup_menu.show_all()

		menu_item = gtk.SeparatorMenuItem()
		self.popup_menu.append(menu_item)
		self.popup_menu.show_all()

		menu_item = gtk.MenuItem(_("Copy"))
		menu_item.connect("activate", self.callback_copy_item)
		self.popup_menu.append(menu_item)

		menu_item = gtk.MenuItem(_("Paste"))
		menu_item.connect("activate", self.callback_paste_item)
		self.popup_menu.append(menu_item)

		menu_item = gtk.MenuItem(_("Delete"))
		menu_item.connect("activate", self.callback_delete_item)
		self.popup_menu.append(menu_item)
		self.popup_menu.show_all()


		self.myserver=myserver
		self.tooltips=tooltips
		self.status_bar=status_bar
		self.context_id=context_id
		self.param_list=scan_items_get_list()
		self.tab_label=tab_label
		self.liststore_op_type = gtk.ListStore(str)


		self.sim_dir=os.path.join(scan_root_dir,sim_name)
		self.tab_name=os.path.basename(os.path.normpath(self.sim_dir))

		self.status_bar.push(self.context_id, self.sim_dir)
		self.set_tab_caption(self.tab_name)

		toolbar = gtk.Toolbar()
		toolbar.set_style(gtk.TOOLBAR_ICONS)
		toolbar.set_size_request(-1, 50)
		pos=0

		image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"add.png"))
		add = gtk.ToolButton(image)
		add.connect("clicked", self.callback_add_item)
		self.tooltips.set_tip(add, _("Add parameter to scan"))
		toolbar.insert(add, pos)
		pos=pos+1


		remove = gtk.ToolButton(gtk.STOCK_CLEAR)
		remove.connect("clicked", self.callback_delete_item)
		self.tooltips.set_tip(remove, _("Delete item"))
		toolbar.insert(remove, pos)
		pos=pos+1

		move = gtk.ToolButton(gtk.STOCK_GO_DOWN)
		move.connect("clicked", self.callback_move_down)
		self.tooltips.set_tip(move, _("Move down"))
		toolbar.insert(move, pos)
		pos=pos+1

		notes = gtk.ToolButton(gtk.STOCK_EDIT)
		notes.connect("clicked", self.callback_notes)
		self.tooltips.set_tip(notes, _("Edit notes"))
		toolbar.insert(notes, pos)
		pos=pos+1

		image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"select.png"))
		quick = gtk.ToolButton(image)
		quick.connect("clicked", self.callback_show_list)
		self.tooltips.set_tip(quick, _("Select parameter to change"))
		toolbar.insert(quick, pos)
		pos=pos+1

		sep = gtk.SeparatorToolItem()
		sep.set_draw(True)
		sep.set_expand(False)
		toolbar.insert(sep, pos)
		pos=pos+1

		image = gtk.Image()
		image.set_from_file(os.path.join(get_image_file_path(),"forward.png"))
		tb_simulate = gtk.ToolButton(image)
		tb_simulate.connect("clicked", self.callback_run_simulation)
		self.tooltips.set_tip(tb_simulate, _("Run simulation"))
		toolbar.insert(tb_simulate, pos)
		pos=pos+1

	        image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"pause.png"))
		self.stop = gtk.ToolButton(image)
		self.tooltips.set_tip(self.stop, _("Stop the simulation"))
		self.stop.connect("clicked", self.callback_stop_simulation)
		toolbar.insert(self.stop, pos)
		pos=pos+1

		sep = gtk.SeparatorToolItem()
		sep.set_draw(True)
		sep.set_expand(False)
		toolbar.insert(sep, pos)
		pos=pos+1

		image = gtk.Image()
		image.set_from_file(os.path.join(get_image_file_path(),"plot.png"))
		plot_select = gtk.MenuToolButton(image,"hello")
		plot_select.connect("clicked", self.callback_gen_plot_command)
		self.tooltips.set_tip(plot_select, _("Find a file to plot"))

		self.plotted_graphs = used_files_menu()
		self.plotted_graphs.init(self.sim_dir,self.callback_last_menu_click)
		plot_select.set_menu(self.plotted_graphs.menu)
		toolbar.insert(plot_select, pos)

		pos=pos+1

	        image = gtk.Image()
   		image.set_from_file(self.icon_theme.lookup_icon("view-refresh", 32, 0).get_filename())
		self.plot_open = gtk.ToolButton(image)
		self.plot_open.connect("clicked", self.callback_plot_results)
		self.plot_open.set_sensitive(False)
		self.tooltips.set_tip(self.plot_open, "Replot the graph")
		toolbar.insert(self.plot_open, pos)
		pos=pos+1

		image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"plot_time.png"))
		self.examine = gtk.ToolButton(image)
		self.tooltips.set_tip(self.examine, _("Examine results in time domain"))
		self.examine.connect("clicked", self.callback_examine)
		toolbar.insert(self.examine, pos)
		pos=pos+1

		sep = gtk.SeparatorToolItem()
		sep.set_draw(True)
		sep.set_expand(False)
		toolbar.insert(sep, pos)
		pos=pos+1

		image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"command.png"))
		insert_command = gtk.ToolButton(image)
		insert_command.connect("clicked", self.callback_insert_command)
		self.tooltips.set_tip(insert_command, _("Insert python command"))
		toolbar.insert(insert_command, pos)
		pos=pos+1
		#reopen_xy = gtk.ToolButton(gtk.STOCK_SELECT_COLOR)
		#reopen_xy.connect("clicked", self.callback_reopen_xy_window)
		#self.tooltips.set_tip(reopen_xy, "Reopen xy window selector")
		#toolbar.insert(reopen_xy, pos)
		#pos=pos+1

		toolbar.show_all()
		self.pack_start(toolbar, False, False, 0)#.add()

		liststore_manufacturers = gtk.ListStore(str)
		for i in range(0,len(self.param_list)):
		    liststore_manufacturers.append([self.param_list[i].name])

		self.liststore_combobox = gtk.ListStore(str, str, str, bool)

		self.config.load(self.sim_dir)
		self.visible=self.config.get_value("#visible",True)
		self.reload_liststore()


		self.treeview = gtk.TreeView(self.liststore_combobox)
		self.treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
		self.treeview.connect("button-press-event", self.on_treeview_button_press_event)


		self.select_param_window=select_param()
		self.select_param_window.init(self.liststore_combobox,self.treeview)

		column_text = gtk.TreeViewColumn(_("Values"))
		column_combo = gtk.TreeViewColumn(_("Parameter to change"))
		column_mirror = gtk.TreeViewColumn(_("Opperation"))

		cellrenderer_combo = gtk.CellRendererCombo()
		cellrenderer_combo.set_property("editable", True)
		cellrenderer_combo.set_property("model", liststore_manufacturers)
		cellrenderer_combo.set_property("text-column", 0)
		cellrenderer_combo.connect("edited", self.combo_changed, self.liststore_combobox)

		column_combo.pack_start(cellrenderer_combo, False)
		column_combo.set_min_width(240)
		column_combo.add_attribute(cellrenderer_combo, "text", 0)

		cellrenderer_mirror = gtk.CellRendererCombo()
		cellrenderer_mirror.set_property("editable", True)
		self.rebuild_liststore_op_type()
		cellrenderer_mirror.set_property("model", self.liststore_op_type)
		cellrenderer_mirror.set_property("text-column", 0)

		cellrenderer_mirror.connect("edited", self.combo_mirror_changed, self.liststore_combobox)

		column_mirror.pack_start(cellrenderer_mirror, True)
		column_mirror.set_min_width(200)
		column_mirror.add_attribute(cellrenderer_mirror, "text", 2)

		cellrenderer_text = gtk.CellRendererText()
		cellrenderer_text.set_property("editable", True)
		cellrenderer_text.connect("edited", self.text_changed, self.liststore_combobox)
		cellrenderer_text.props.wrap_width = 400
		cellrenderer_text.props.wrap_mode = gtk.WRAP_WORD

		column_text.pack_start(cellrenderer_text, False)
		column_text.set_min_width(400)
		column_text.add_attribute(cellrenderer_text, "text", 1)

		renderer_enable = gtk.CellRendererToggle()
		#renderer_enable.set_property("activatable", True)
		renderer_enable.set_activatable(True)
		renderer_enable.connect("toggled", self.toggled_cb, self.liststore_combobox)
		column_enable = gtk.TreeViewColumn(_("Enabled"),renderer_enable)
		column_enable.set_max_width(50)
		column_enable.set_visible(False)
	
		column_enable.add_attribute(renderer_enable, "active", 3)
		column_enable.pack_start(renderer_enable, False)

		self.treeview.append_column(column_combo)
		self.treeview.append_column(column_text)
		self.treeview.append_column(column_mirror)
		self.treeview.append_column(column_enable)

		#window.connect("destroy", lambda w: gtk.main_quit())
		scrolled_window = gtk.ScrolledWindow()
		scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
		scrolled_window.add(self.treeview)
		scrolled_window.set_size_request(1000, 500)
		#scrolled_window.set_min_content_height(200)

		self.pack_start(scrolled_window, True, True, 0)
		self.treeview.show()
		self.show_all()

		if self.visible==False:
			self.hide()
Example #2
0
	def __init__(self):

		gobject.GObject.__init__(self)

		self.my_server=server()
		self.my_server.init(os.getcwd())
		self.my_server.statusicon.connect('popup-menu', self.on_status_icon_right_click)
		self.my_server.setup_gui(self.gui_sim_start,self.gui_sim_stop)

		if running_on_linux()==True:
			DBusGMainLoop(set_as_default=True)
			self.bus = dbus.SessionBus()
			self.bus.add_match_string_non_blocking("type='signal',interface='org.my.opvdm'")
			self.bus.add_message_filter(self.adbus)

		else:
			self.win_pipe=win_pipe()
			self.win_pipe.connect('new-data', self.win_dbus)
			self.win_pipe.start()

		self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
		#self.window.set_size_request(-1,1000)
		self.window.set_border_width(10)
		self.window.set_title(_("Organic Photovoltaic Device Model (www.opvdm.com)"))

		splash=splash_window()
		splash.init()

		temp_error=ver_error()
		print temp_error
		if len(temp_error)>0:
				md = gtk.MessageDialog(self.window,gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, temp_error)
				md.run()
				md.destroy()

		self.undo_list=undo_list_class()
		self.undo_list.init()


		self.experiment_window=None

		self.fxexperiment_window=None

		self.qe_window=None

		self.win_list=windows()
		self.win_list.load()

		self.config=config()
		#table = gtk.Table(3,6,False)

		self.window.set_icon_from_file(os.path.join(get_image_file_path(),"image.jpg"))

		

		self.show_tabs = True
		self.show_border = True

		self.menu_items = (
		    ( _("/_File"),         None,         None, 0, "<Branch>" ),
			(_("/File/_New simulation"), "<control>N", self.callback_new, 0, "<StockItem>", "gtk-new" ),
			(_("/File/_Open simulation"), "<control>O", self.callback_open, 0, "<StockItem>", "gtk-open" ),
		    ( _("/File/_Export data"),     None, self.callback_export, 0, "<StockItem>", "gtk-save" ),
		    ( _("/File/Import data"),     None, self.callback_import, 0 , "<StockItem>", "gtk-harddisk"),
		    ( _("/File/Import from library"),     None, self.callback_import_from_lib, 0 , "<StockItem>", "gtk-harddisk"),
		    ( _("/File/Quit"),     "<control>Q", gtk.main_quit, 0, "<StockItem>", "gtk-quit" ),
		    ( _("/_Simulate"),      None,         None, 0, "<Branch>" ),
		    ( _("/Simulate/Run"),  None,         self.callback_simulate, 0, "<StockItem>", "gtk-media-play" ),
		    ( _("/Simulate/Parameter scan"),  None,         self.callback_scan , 0, None ),
		    ( _("/Simulate/Start cluster server"),  None,         self.callback_start_cluster_server , 0, None ),
		    ( _("/_View"),      None,         None, 0, "<Branch>" ),
		    ( _("/_Plots"),      None,         None, 0, "<Branch>" ),
		    ( _("/Plots/Plot simulation result"),  None,         self.callback_plot_select, 0, "<StockItem>", "gtk-open"),
		    ( _("/_Plots/"),     None, None, 0, "<Separator>" ),
		    ( _("/_Help"),         None,         None, 0, "<LastBranch>" ),
			( _("/_Help/Help Index"),   None,         self.callback_help, 0, "<StockItem>", "gtk-help"  ),
			

		    ( _("/_Help/About"),   None, self.callback_about_dialog, 0, "<StockItem>", "gtk-about" ),
		    )
		pos=0

		self.menubar = self.get_main_menu(self.window)

		#a = (( "/Plots/Plot after simulation",  None, self.callback_plot_after_run_toggle, 0, "<ToggleItem>" ),   )
		#self.item_factory.create_items( a, )


		#a = (( "/Plots/One plot window",  None, self.callback_set_plot_auto_close, 0, "<ToggleItem>" ),   )
		#self.item_factory.create_items( a, )


		#table.show()
		self.window.connect("destroy", gtk.main_quit)

		self.tooltips = gtk.Tooltips()

		self.window.set_size_request(-1, 780)
		main_vbox = gtk.VBox(False, 5)
		main_vbox.set_border_width(1)
		self.window.add(main_vbox)
		#window.add(table)
		main_vbox.show()


		toolbar = gtk.Toolbar()
		toolbar.set_style(gtk.TOOLBAR_ICONS)
		toolbar.set_size_request(-1, 50)

		open_sim = gtk.ToolButton(gtk.STOCK_OPEN)
		self.tooltips.set_tip(open_sim, _("Open a simulation"))
		toolbar.insert(open_sim, pos)
		pos=pos+1

		#self.save_sim = gtk.ToolButton(gtk.STOCK_SAVE)
		#self.tooltips.set_tip(self.save_sim, "Save a simulation")
		#toolbar.insert(self.save_sim, pos)
		#pos=pos+1

		new_sim = gtk.ToolButton(gtk.STOCK_NEW)
		self.tooltips.set_tip(new_sim, _("Make a new simulation"))
		toolbar.insert(new_sim, pos)
		pos=pos+1

		sep_lhs = gtk.SeparatorToolItem()
		sep_lhs.set_draw(True)
		sep_lhs.set_expand(False)
		toolbar.insert(sep_lhs, pos)
		pos=pos+1

		self.undo = gtk.ToolButton(gtk.STOCK_UNDO)
		self.tooltips.set_tip(self.undo, "Undo")
		toolbar.insert(self.undo, pos)
		self.undo.connect("clicked", self.callback_undo)
		pos=pos+1

		sep_lhs = gtk.SeparatorToolItem()
		sep_lhs.set_draw(True)
		sep_lhs.set_expand(False)
		toolbar.insert(sep_lhs, pos)
		pos=pos+1

	        image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"play.png"))
		self.play = gtk.ToolButton(image)
		self.tooltips.set_tip(self.play, _("Run the simulation"))
		toolbar.insert(self.play, pos)
		self.play.connect("clicked", self.callback_simulate)
		pos=pos+1

		image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"forward.png"))
		self.tb_run_scan = gtk.ToolButton(image)
		self.tb_run_scan.connect("clicked", self.callback_run_scan)
		self.tooltips.set_tip(self.tb_run_scan, _("Run parameter scan"))
		toolbar.insert(self.tb_run_scan, pos)
		self.tb_run_scan.set_sensitive(False)
		pos=pos+1

		if debug_mode()==True:
			image = gtk.Image()
	   		image.set_from_file(os.path.join(get_image_file_path(),"fit.png"))
			self.tb_run_fit = gtk.ToolButton(image)
			self.tb_run_fit.connect("clicked", self.callback_run_fit)
			self.tooltips.set_tip(self.tb_run_fit, _("Run a fit command"))
			toolbar.insert(self.tb_run_fit, pos)
			self.tb_run_fit.set_sensitive(True)
			pos=pos+1

	        image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"pause.png"))
		self.stop = gtk.ToolButton(image )
		self.tooltips.set_tip(self.stop, _("Stop the simulation"))
		self.stop.connect("clicked", self.callback_simulate_stop)
		toolbar.insert(self.stop, pos)
		pos=pos+1

		sep = gtk.SeparatorToolItem()
		sep.set_draw(True)
		sep.set_expand(False)
		toolbar.insert(sep, pos)
		pos=pos+1

		image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"scan.png"))
		self.param_scan = gtk.ToolButton(image)
		self.param_scan.connect("clicked", self.callback_scan)
		self.tooltips.set_tip(self.param_scan, _("Parameter scan"))
		toolbar.insert(self.param_scan, pos)
		pos=pos+1

		sep = gtk.SeparatorToolItem()
		sep.set_draw(True)
		sep.set_expand(False)
		toolbar.insert(sep, pos)
		pos=pos+1

	        image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"plot.png"))
		self.plot_select = gtk.MenuToolButton(image,"hello")
		self.tooltips.set_tip(self.plot_select, _("Find a file to plot"))
		self.plotted_graphs = used_files_menu()
		self.plot_select.set_menu(self.plotted_graphs.menu)
		toolbar.insert(self.plot_select, pos)
		self.plot_select.connect("clicked", self.callback_plot_select)
		self.plot_select.set_sensitive(False)
		pos=pos+1

		#image = gtk.Image()
   		#image.set_from_file(os.path.join(get_image_file_path(),"refresh.png"))
		#self.plot_open = gtk.ToolButton(image)
		#self.tooltips.set_tip(self.plot_open, "Replot the graph")
		#toolbar.insert(self.plot_open, pos)
		#self.plot_open.set_sensitive(False)
		#os=pos+1

		image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"plot_time.png"))
		self.examine = gtk.ToolButton(image)
		self.tooltips.set_tip(self.examine, _("Examine results in time domain"))
		self.examine.connect("clicked", self.callback_examine)
		toolbar.insert(self.examine, pos)
		pos=pos+1

		sep = gtk.SeparatorToolItem()
		sep.set_draw(True)
		sep.set_expand(False)
		toolbar.insert(sep, pos)
		pos=pos+1



		image = gtk.Image()
	   	image.set_from_file(os.path.join(get_image_file_path(),"time.png"))
		self.experiment_window_button = gtk.ToolButton(image)
		self.tooltips.set_tip(self.experiment_window_button, _("Edit the time mesh"))
		self.experiment_window_button.connect("clicked", self.callback_edit_experiment_window)
		toolbar.insert(self.experiment_window_button, pos)
		pos=pos+1

		image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"spectrum.png"))
		self.examine = gtk.ToolButton(image)
		self.tooltips.set_tip(self.examine, _("Frequency domain mesh editor"))
		self.examine.connect("clicked", self.callback_fxexperiment_window)
		toolbar.insert(self.examine, pos)
		pos=pos+1

		sep2 = gtk.SeparatorToolItem()
		sep2.set_draw(False)
		sep2.set_expand(True)
		toolbar.insert(sep2, pos)
		pos=pos+1


		help = gtk.ToolButton(gtk.STOCK_HELP)
		self.tooltips.set_tip(help, "Help")
		help.connect("clicked", self.callback_help)
		toolbar.insert(help, pos)
		pos=pos+1


		#quittb = gtk.ToolButton(gtk.STOCK_QUIT)
		#self.tooltips.set_tip(quittb, "Quit")
		#toolbar.insert(quittb, pos)
		#quittb.connect("clicked", gtk.main_quit)
		#pos=pos+1

		new_sim.connect("clicked", self.callback_new)
		open_sim.connect("clicked", self.callback_open)
		#self.save_sim.connect("clicked", self.callback_export)

		#self.plot_open.connect("clicked", self.callback_plot_open)

		toolbar1=self.make_tool_box1()


		toolbar.show_all()



		main_vbox.pack_start(self.menubar, False, True, 0)
		handlebox = gtk.HandleBox()
		handlebox.set_snap_edge(gtk.POS_LEFT)
		handlebox.show()

		toolbar.set_size_request(1000, -1)

		tb_vbox=gtk.VBox()
		tb_vbox.add(toolbar)
		tb_vbox.add(toolbar1)
		tb_vbox.show()



		handlebox.add(tb_vbox)

		main_vbox.pack_start(handlebox, False, False, 0)

		self.window.connect("delete-event", self.callback_close_window) 

		self.win_list.set_window(self.window,"main_window")



		self.menubar.show()

		self.make_window2(main_vbox)

		self.window.show()


		process_events()