def __newFile(self): self.__root.title("new file - pyRPA") self.__file = None self.__thisActionListBox.delete(0, END) self.__thisScript.__del__() self.__thisVariableList.__del__() print(self.__thisVariableList.__getleng__()) self.__thisScript = script.Script() self.__thisVariableList = variablelist.VariableList() self.__thisLibraryTreeView.item("Main Node", open=True) self.__thisLibraryTreeView.item("Library Node", open=True)
from selenium import webdriver from tkinter.messagebox import * import VariableList as variablelist import Variable as variable variable_list = variablelist.VariableList() print(variable_list.get_item("url").get_cur_value()) #showinfo("",)
CompareList3.append([ NomFile, "nominal", FileUp, "Up", FileDown, "Down", "Comparison_Syst/", "lepjets", entry[0] ]) for entry in CompareList2: InputFile1 = MainFolder1 + "/" + entry[0] InputFile2 = MainFolder2 + "/" + entry[2] InputName1 = entry[1] InputName2 = entry[3] OutputFolder = os.getcwd() + "/" + entry[4] Channel = entry[5] os.system("mkdir -p " + OutputFolder) VarList = VariableList.ReturnVariableListTemplates("", Channel) for Var in VarList: HistoName = Var[5] HistoTitle = Var[6] OutputFile = OutputFolder + "/" + HistoName.replace("h_", "") + ".pdf" MakeComparisonPlots(OutputFile, HistoName, HistoTitle, InputFile1, InputName1, InputFile2, InputName2) for entry in CompareList3: InputFile1 = entry[0] InputFile2 = entry[2] InputFile3 = entry[4] InputName1 = entry[1]
def run_node(self): variablelist.VariableList().get_item(self.name).set_cur_value(self.value)
class MainWindow(object): rootframe = Tk() width = 800 height = 620 rootframe.geometry('{}x{}'.format(width, height)) # menu bar menubar = Menu(rootframe) filemenu = Menu(menubar, tearoff=0) runmenu = Menu(menubar, tearoff=0) viewmenu = Menu(menubar, tearoff=0) helpmenu = Menu(menubar, tearoff=0) # create all of the main containers topframe = Frame(rootframe, bg='cyan', width=450, height=50, pady=3) center = Frame(rootframe, bg='gray2', width=50, height=40, padx=3, pady=3) # btmframe = Frame(rootframe, bg='white', width=450, height=45, pady=3) # btmframe2 = Frame(rootframe, bg='lavender', width=450, height=60, pady=3) # layout all of the main containers rootframe.grid_rowconfigure(1, weight=1) rootframe.grid_columnconfigure(0, weight=1) topframe.grid(row=0, sticky="ew") center.grid(row=1, sticky="nsew") # create the center widgets center.grid_rowconfigure(0, weight=1) center.grid_columnconfigure(1, weight=1) controlleft = Frame(center, bg='blue', width=300) controlmid = Frame(center, bg='yellow', width=250, padx=3, pady=3) controlright = Frame(center, bg='green', width=300, padx=3, pady=3) controlleft.grid(row=0, column=0, sticky="ns") controlmid.grid(row=0, column=1, sticky="nsew") controlright.grid(row=0, column=2, sticky="ns") bottompanel = PanedWindow(rootframe, orient=VERTICAL) panelframe = Frame(bottompanel, bg="#9dc8e3") bottompanel.add(panelframe, minsize=150) bottompanel.grid(row=3, column=0, sticky="nsew") top = Label(panelframe, text="PANEL") top.pack(fill=BOTH, expand=1) librarytreeviewscollbar = Scrollbar(controlleft) librarytreeview = ttk.Treeview(controlleft) librarytreeviewscollbar.config(command=librarytreeview.yview) librarytreeviewscollbar.pack(side="right", fill="y") librarytreeview.config(show="tree", yscrollcommand=librarytreeviewscollbar.set) librarytreeview.pack(side="left", fill="y") actionlistbox = Listbox(controlmid, width=230) actionlistbox.pack(side="left", fill="y") actionlistboxscollbar = Scrollbar(controlmid, orient="vertical") actionlistboxscollbar.config(command=actionlistbox.yview) actionlistboxscollbar.pack(side="right", fill="y") actionlistbox.config(yscrollcommand=actionlistboxscollbar.set) selectlabel = Label(controlright, width=30) selectlabel.pack(fill="both") mainscript = script.Script() variablelist = variablelist.VariableList() file = None def __init__(self, **kwargs): # Set icon try: self.rootframe.wm_iconbitmap("robot-ico.ico") except: pass # Window title self.rootframe.title("NewFile - pyRPA") self.menubar.add_cascade(label="File", menu=self.filemenu) # To open new file self.filemenu.add_command(label="New", command=self.new_file_command) # To open a already existing file self.filemenu.add_command(label="Open", command=self.open_file_command) # To save current file self.filemenu.add_command(label="Save", command=self.save_file_command) # To save current file self.filemenu.add_command(label="Save As", command=self.save_file_as_command) # To create a line in the menu self.filemenu.add_separator() # To create a Script help self.menubar.add_cascade(label="Script", menu=self.runmenu) # To run the scenario self.runmenu.add_command(label="Run", command=self.run_script) # To Exit application self.filemenu.add_command(label="Exit", command=self.quit_application) # To create a menu help self.menubar.add_cascade(label="Help", menu=self.helpmenu) # To create a feature of description of the application self.helpmenu.add_command(label="About", command=self.show_about) self.rootframe.config(menu=self.menubar) # self.actionlistbox.config(yscrollcommand=self.actionlistboxscollbar.set) # self.actionlistbox.grid(row=0, column=3, columnspan=2, rowspan=6) # self.actionlistbox.bind('<<ListboxSelect>>', self.onselect) self.librarytreeview.bind("<Double-1>", self.event_on_add) self.actionlistbox.bind("<ButtonRelease-1>", self.event_on_select) self.actionlistbox.bind("<Double-1>", self.event_on_access) # self.librarytreeview.bind("<ButtonPress-1>", self.bDown) # self.librarytreeview.bind("<ButtonRelease-1>", self.bUp) # self.librarytreeview.bind("<B1-Motion>", self.bMove) # self.actionlistboxscollbar.config(command=self.__thisActionListBox.yview) # self.actionlistboxscollbar.grid(row=0, column=6, columnspan=1, rowspan=6) self.load_tree_view() def event_on_access(self, event): selector = event.widget index = int(selector.curselection()[0]) index_value = selector.get(index) if hasattr(self.mainscript.node_list[index], 'accessible'): if self.mainscript.node_list[index].accessible == True: self.access_node(self.mainscript.node_list[index]) return def access_node(self, element): print("accessed") pass def event_on_select(self, event): selector = event.widget index = int(selector.curselection()[0]) index_value = selector.get(index) self.selectlabel.config(text=index_value + " setting") self.load_properties(self.mainscript.node_list[index]) return def load_properties(self, element): properties_dic = element.load_properties_list() def event_on_add(self, event): selected = self.librarytreeview.focus() if self.librarytreeview.item(selected)['tags'] != ['Fd']: self.actionlistbox.insert( END, self.librarytreeview.item( self.librarytreeview.focus())['text']) self.add_action_to_script( self.librarytreeview.item( self.librarytreeview.focus())['text']) return def add_action_to_script(self, type): if type == "assign": self.variablelist.__adduniqueitem__(variable.Variable( "driver", "")) self.variablelist.__adduniqueitem__( variable.Variable("url", "http://gmail.com")) #self.mainscript.__additem__(assnode.AssignNode("abc", "123")) elif type == "if-else": self.mainscript.__additem__(ifnode.IfNode("", "", "")) elif type == "node-base": self.mainscript.__additem__(nodebase.NodeBase("", "test_func1")) elif type == "test_func1": self.mainscript.__additem__( nodebase.NodeBase("node-base1", "test_func1")) elif type == "test_func2": self.mainscript.__additem__( nodebase.NodeBase("node-base2", "test_func2")) elif type == "open_chrome": self.mainscript.__additem__( nodebase.NodeBase("node-base1", "open_chrome")) elif type == "open_gmail": self.mainscript.__additem__( nodebase.NodeBase("node-base2", "open_gmail")) elif type == "message-box": self.mainscript.__additem__( nodebase.NodeBase("node-base2", "message_box")) elif type == "group": self.mainscript.__additem__( nodegroup.NodeGroup("node-group1", "group1")) return def bDown(self, event): tv = event.widget if tv.identify_row(event.y) not in tv.selection(): tv.selection_set(tv.identify_row(event.y)) print(tv.selection_set(tv.identify_row(event.y))) return def bUp(self, event): tv = event.widget if tv.identify_row(event.y) in tv.selection(): tv.selection_set(tv.identify_row(event.y)) return def bMove(self, event): tv = event.widget moveto = tv.index(tv.identify_row(event.y)) for s in tv.selection(): tv.move(s, '', moveto) def run(self): # Run main application self.rootframe.mainloop() def new_file_command(self): pass def open_file_command(self): self.file = askopenfilename(defaultextension=".txt", filetypes=[("All Files", "*.*"), ("Text Documents", "*.txt")]) if self.file == "": # no file to open self.file = None else: # Try to open the file # set the window title self.rootframe.title(os.path.basename(self.file) + " - Notepad") # self.__thisTextArea.delete(1.0,END) file = open(self.file, "r") self.mainscript = json.loads(file.read()) file.close() def save_file_command(self): if self.file == None: # Save as new file self.file = asksaveasfilename(initialfile='Untitled.txt', defaultextension=".txt", filetypes=[("All Files", "*.*"), ("Text Documents", "*.txt")]) if self.file == "": self.file = None else: # Try to save the file file = open(self.file, "w") file.write(self.mainscript.toJSON()) #json.dump(self.mainscript.toJSON(), file) file.close() # Change the window title self.rootframe.title(os.path.basename(self.file)) else: file = open(self.file, "w") file.write(self.mainscript.toJSON()) #print(self.mainscript.toJSON()) #json.dump(self.mainscript.toJSON(), file) file.close() def save_file_as_command(self): pass def run_script(self): self.mainscript.__run__() pass def quit_application(self): pass def show_about(self): pass def load_tree_view(self): # create node folder # list_node = ( # "group", "node-base", "assign", "if-else", "multi-if", "for-loop", "while-loop", "do-while-loop", "break", # "continue", "try-catch", "subscript-call", "subscript-create", "return","message-box") nodeList = ("group", "node-base", "assign", "if-else", "message-box") f1 = self.librarytreeview.insert("", 0, iid="Main Node", text="Node", tags="Fd") for i in nodeList: self.librarytreeview.insert(f1, "end", text=i) # create library folder f2 = self.librarytreeview.insert("", "end", iid="Library Node", text="Library", tags="Fd") self.librarytreeview.insert(f2, "end", text="test_func1") self.librarytreeview.insert(f2, "end", text="test_func2") self.librarytreeview.insert(f2, "end", text="open_chrome") self.librarytreeview.insert(f2, "end", text="open_gmail") return
#CompareList3.append(["Output_Win_2tags_emu/Histograms_emu_2015_16_Merged/Merge_ttbar_MC16a.root", "emu", "Output_Win_2tags_mumu/Histograms_mumu_2015_16_Merged/Merge_ttbar_MC16a.root", "mumu", "Output_Win_2tags_ee/Histograms_ee_2015_16_Merged/Merge_ttbar_MC16a.root", "ee", "Comparison_dilepton_channels_ttbar_MC16a/", "dilepton"]) #CompareList3.append(["Output_Win_2tags_emu/Histograms_emu_2017_Merged/Merge_ttbar_MC16c.root", "emu", "Output_Win_2tags_mumu/Histograms_mumu_2017_Merged/Merge_ttbar_MC16c.root", "mumu", "Output_Win_2tags_ee/Histograms_ee_2017_Merged/Merge_ttbar_MC16c.root", "ee", "Comparison_dilepton_channels_ttbar_MC16c/", "dilepton"]) #CompareList3.append(["Output_Win_2tags/Histograms_dilepton_2017_Merged/Merge_ttbar_MC16c.root", "2017", "Output_Win_2tags_2016/Histograms_dilepton_2016_Merged/Merge_ttbar_MC16a.root", "2016", "Output_Win_2tags_2015/Histograms_dilepton_2015_Merged/Merge_ttbar_MC16a.root", "2015", "Comparison_dilepton_dataPeriods_ttbar/", "dilepton"]) #CompareList3.append(["Output_Win_MET_2tags/Histograms_lepjets_2017_Merged/Merge_ttbar_MC16c.root", "2017", "Output_Win_MET_2tags_2016/Histograms_lepjets_2016_Merged/Merge_ttbar_MC16a.root", "2016", "Output_Win_MET_2tags_2015/Histograms_lepjets_2015_Merged/Merge_ttbar_MC16a.root", "2015", "Comparison_lepjets_dataPeriods_ttbar/", "lepjets"]) for entry in CompareList2: InputFile1 = MainFolder + "/" + entry[0] InputFile2 = MainFolder + "/" + entry[2] InputName1 = entry[1] InputName2 = entry[3] OutputFolder = os.getcwd() + "/" + entry[4] Channel = entry[5] os.system("mkdir -p " + OutputFolder) VarList = VariableList.ReturnVariableListSimple("", Channel) for Var in VarList: HistoName = Var[5] HistoTitle = Var[6] OutputFile = OutputFolder + "/" + HistoName.replace("h_", "") + ".pdf" MakeComparisonPlots(OutputFile, HistoName, HistoTitle, InputFile1, InputName1, InputFile2, InputName2) for entry in CompareList3: InputFile1 = MainFolder + "/" + entry[0] InputFile2 = MainFolder + "/" + entry[2] InputFile3 = MainFolder + "/" + entry[4] InputName1 = entry[1]
def FillHistograms(DSID, InputFolder, OutputFile, DataMCFlag, Tree, Weight, Channel, Flag, Cuts): #print DSID," ",DataMCFlag," ",Channel Lumi = 36184.86 if "MC16d" in DataMCFlag: Lumi = 43813.7 HelpDataMCFlag = DataMCFlag if "data" in DataMCFlag or "Data" in DataMCFlag: if "2017" in OutputFile: HelpDataMCFlag = "MC16d" else: HelpDataMCFlag = "MC16a" VariableFlag = ReturnVariableFlag(Channel, HelpDataMCFlag) VarList = VariableList.ReturnVariableListSimple(DataMCFlag, VariableFlag) InputFiles = glob.glob(InputFolder + "/*root*") if Flag == "Template": VarList = VariableList.ReturnVariableListTemplate( DataMCFlag, VariableFlag) if Flag == "KLFPerf": VarList = VariableList.ReturnVariablesKLFPerf() BKHistos = [] ChannelFlag = Channel NormEvents = 0.0 NormEvents_Tree = 0.0 # these weights are needed to evaluate ISR/FSR uncertainties! NormEvents_Tree_FSR20 = 0.0 NormEvents_Tree_FSR05 = 0.0 NormEvents_Tree_ISR20 = 0.0 NormEvents_Tree_ISR05 = 0.0 NormEvents_Tree_ME20 = 0.0 NormEvents_Tree_ME05 = 0.0 ChannelList = ReturnChannelList(Channel, HelpDataMCFlag) if "data" in DSID or "grp" in InputFolder: Flag = "2017" if "data15" in DSID or "grp15" in InputFolder: Flag = "2015" if "data16" in DSID or "grp16" in InputFolder: Flag = "2016" ChannelFlag = "(" counter = 0 for i in range(0, len(ChannelList)): entry = ChannelList[i] entry = entry.replace("", "") Histo = AddBKHistograms(InputFiles, entry) BKHistos.append([Histo, "BK_" + entry]) NormEvents = Histo.GetBinContent(1) if i < len(ChannelList) - 1: ChannelFlag += entry + " || " else: ChannelFlag += entry + ")" # or get normalisation from trees fT_weights = MakeChain(InputFiles, "sumWeights") entries_weights = fT_weights.GetEntries() if not "Data" in DataMCFlag: for j in range(0, entries_weights): fT_weights.GetEntry(j) NormEvents_Tree += fT_weights.totalEventsWeighted_mc_generator_weights[ 0] if DSID == "410470" or DSID == "410472" or DSID == "410480" or DSID == "410482": NormEvents_Tree_FSR20 += fT_weights.totalEventsWeighted_mc_generator_weights[ 198] NormEvents_Tree_FSR05 += fT_weights.totalEventsWeighted_mc_generator_weights[ 199] NormEvents_Tree_ISR20 += fT_weights.totalEventsWeighted_mc_generator_weights[ 194] NormEvents_Tree_ISR05 += fT_weights.totalEventsWeighted_mc_generator_weights[ 193] NormEvents_Tree_ME20 += fT_weights.totalEventsWeighted_mc_generator_weights[ 6] NormEvents_Tree_ME05 += fT_weights.totalEventsWeighted_mc_generator_weights[ 5] else: NormEvents_Tree_FSR20 = 1 NormEvents_Tree_FSR05 = 1 NormEvents_Tree_ISR20 = 1 NormEvents_Tree_ISR05 = 1 NormEvents_Tree_ME20 = 1 NormEvents_Tree_ME05 = 1 else: NormEvents_Tree = 1 NormEvents_Tree_FSR20 = 1 NormEvents_Tree_FSR05 = 1 NormEvents_Tree_ISR20 = 1 NormEvents_Tree_ISR05 = 1 NormEvents_Tree_ME20 = 1 NormEvents_Tree_ME05 = 1 # first thing to do: get the cross-sections from TopDataPrep, for the moment store the file in here CrossSection = GetCrossSection(DSID) NormFactor = CrossSection * Lumi / NormEvents #_Tree NormFactor_FSR20 = CrossSection * Lumi / NormEvents_Tree_FSR20 NormFactor_FSR05 = CrossSection * Lumi / NormEvents_Tree_FSR05 NormFactor_ISR20 = CrossSection * Lumi / ( NormEvents_Tree_ISR20 * NormEvents_Tree_ME20 / NormEvents_Tree) NormFactor_ISR05 = CrossSection * Lumi / ( NormEvents_Tree_ISR05 * NormEvents_Tree_ME05 / NormEvents_Tree) NormFactorList = [] NormFactorList.append([NormFactor, "NormFactor"]) NormFactorList.append([NormFactor_FSR20, "NormFactor_FSR20"]) NormFactorList.append([NormFactor_FSR05, "NormFactor_FSR05"]) NormFactorList.append([NormFactor_ISR20, "NormFactor_ISR20"]) NormFactorList.append([NormFactor_ISR05, "NormFactor_ISR05"]) # make chain of input files fT = MakeChain(InputFiles, Tree + "") entries = fT.GetEntries() fF_out = TFile(OutputFile, "RECREATE") FullWeight = "weight_mc*weight_pileup*weight_leptonSF*weight_jvt*weight_bTagSF_MV2c10_77*" + str( NormFactor) #if DSID == "410470": # FullWeight = "mc_generator_weights[0]*weight_pileup*weight_leptonSF*weight_jvt*weight_bTagSF_MV2c10_77*"+str(NormFactor) #198 isr:muRfac=10_fsr:muRfac=20 #199 isr:muRfac=10_fsr:muRfac=05 if DataMCFlag == "MC15": FullWeight = "weight_mc*weight_pileup*weight_leptonSF*weight_jvt*weight_bTagSF_MV2c10_77*" + str( NormFactor) if "Data" in DataMCFlag: FullWeight = "1.0" #print str(FullWeight)+Cuts # now loop over all input variables, project them and write them out into dedicated root file for Var in VarList: varName = Var[0] NBins = Var[1] lowEdge = Var[2] highEdge = Var[3] doOverflow = Var[4] histName = Var[5] h_tmp = TH1D(histName, histName, NBins, lowEdge, highEdge) h_tmp.Sumw2() if "+" in varName: varNameList = varName.split("+") counter = 0 for varNameEntry in varNameList: if counter == 0: fT.Project(h_tmp.GetName(), varNameEntry, ChannelFlag + "*" + str(FullWeight) + Cuts) counter += 1 else: h_tmp2 = TH1D(histName + "_2", histName + "_2", NBins, lowEdge, highEdge) h_tmp2.Sumw2() fT.Project(h_tmp2.GetName(), varNameEntry, ChannelFlag + "*" + str(FullWeight) + Cuts) h_tmp.Add(h_tmp2) else: fT.Project(h_tmp.GetName(), varName, ChannelFlag + "*" + str(FullWeight) + Cuts) if doOverflow: h_tmp = AddOverflows(h_tmp) h_tmp.Write(histName) for entry in BKHistos: entry[0].Write(entry[1]) # now call here the tree maker OutputFileTree = OutputFile.replace("Unmerged//Histogram", "Unmerged/Tree") InputTree = PrepareInputTrees(fT, VariableFlag, NormFactorList, OutputFileTree, ChannelFlag + "*" + Cuts, DSID, Tree) fF_out.Close()
class MainWindow(object): __root = Tk() # default window width and height __thisWidth = 540 __thisHeight = 300 __thisMenuBar = Menu(__root) __thisFileMenu = Menu(__thisMenuBar, tearoff=0) __thisRunMenu = Menu(__thisMenuBar, tearoff=0) __thisViewMenu = Menu(__thisMenuBar, tearoff=0) __thisHelpMenu = Menu(__thisMenuBar, tearoff=0) __thisRunButton = Button(__root) __thisAddButton = Button(__root) __thisDeleteButton = Button(__root) __thisActionListBox = Listbox(__root) __thisActionListBoxScrollBar = Scrollbar(__root) __thisLibraryTreeView = ttk.Treeview(__root) __thisLibraryTreeViewScrollBar = Scrollbar(__root) __thisSelectLabel = Label(__root) # __thisTopWinDow = Toplevel() __thisScript = script.Script() __thisVariableList = variablelist.VariableList() __file = None def __init__(self, **kwargs): # Set icon try: self.__root.wm_iconbitmap("robot-ico.ico") except: pass # Set window size (the default is 300x300) try: self.__thisWidth = kwargs['width'] except KeyError: pass try: self.__thisHeight = kwargs['height'] except KeyError: pass # Set the window text self.__root.title("NewFile - pyRPA") # Center the window screenWidth = self.__root.winfo_screenwidth() screenHeight = self.__root.winfo_screenheight() # For left-alling left = (screenWidth / 2) - (self.__thisWidth / 2) # For right-allign top = (screenHeight / 2) - (self.__thisHeight / 2) # For top and bottom self.__root.geometry('%dx%d+%d+%d' % (self.__thisWidth, self.__thisHeight, left, top)) # To open new file self.__thisFileMenu.add_command(label="New", command=self.__newFile) # To open a already existing file self.__thisFileMenu.add_command(label="Open", command=self.__openFile) # To save current file self.__thisFileMenu.add_command(label="Save", command=self.__saveFile) # To create a line in the menu self.__thisFileMenu.add_separator() # To Exit application self.__thisFileMenu.add_command(label="Exit", command=self.__quitApplication) self.__thisMenuBar.add_cascade(label="File", menu=self.__thisFileMenu) self.__thisViewMenu.add_command(label="Editor", command=self.__openEditor) # To give a feature of cut self.__thisViewMenu.add_command(label="Cut", command=self.__cut) # to give a feature of copy self.__thisViewMenu.add_command(label="Copy", command=self.__copy) # To give a feature of paste self.__thisViewMenu.add_command(label="Paste", command=self.__paste) # To give a feature of editing self.__thisMenuBar.add_cascade(label="View", menu=self.__thisViewMenu) self.__thisMenuBar.add_cascade(label="Script", menu=self.__thisRunMenu) self.__thisRunMenu.add_command(label="Run", command=self.__runScript) # To create a menu help self.__thisMenuBar.add_cascade(label="Help", menu=self.__thisHelpMenu) # To create a feature of description of the application self.__thisHelpMenu.add_command(label="About pyRPA", command=self.__showAbout) self.__root.config(menu=self.__thisMenuBar) # create run button self.__thisRunButton.config(text='Run', command=self.__runScript) self.__thisRunButton.grid(row=0, column=1, rowspan=1, columnspan=1) # create add node button self.__thisAddButton.config(text='Add', command=self.__addNode) self.__thisAddButton.grid(row=0, column=2, rowspan=1, columnspan=1) # create delete node button self.__thisDeleteButton.config(text='Delete', command=self.__deleteNode) self.__thisDeleteButton.grid(row=0, column=3, rowspan=1, columnspan=1) # create treeview for show available library self.__thisLibraryTreeView.config( show="tree", yscrollcommand=self.__thisLibraryTreeViewScrollBar.set) self.__thisLibraryTreeView.grid(row=1, column=0, columnspan=2, rowspan=4) self.__thisLibraryTreeViewScrollBar.config( command=self.__thisLibraryTreeView.yview) self.__thisLibraryTreeViewScrollBar.grid(row=1, column=2, columnspan=1, rowspan=4) self.__loadTreeView() # create listbox for show available library self.__thisActionListBox.config( yscrollcommand=self.__thisActionListBoxScrollBar.set) self.__thisActionListBox.grid(row=0, column=3, columnspan=2, rowspan=6) self.__thisActionListBox.bind('<<ListboxSelect>>', self.onselect) self.__thisActionListBoxScrollBar.config( command=self.__thisActionListBox.yview) self.__thisActionListBoxScrollBar.grid(row=0, column=6, columnspan=1, rowspan=6) self.__thisSelectLabel.grid(row=0, column=7) def onselect(self, evt): selector = evt.widget index = int(selector.curselection()[0]) index_value = selector.get(index) self.__thisSelectLabel.config(text=index_value) return def __quitApplication(self): self.__root.destroy() return def __loadTreeView(self): # create node folder # list_node = ( # "group", "node-base", "assign", "if-else", "multi-if", "for-loop", "while-loop", "do-while-loop", "break", # "continue", "try-catch", "subscript-call", "subscript-create", "return","message-box") list_node = ("group", "node-base", "assign", "if-else", "message-box") f1 = self.__thisLibraryTreeView.insert("", 0, iid="Main Node", text="Node") for i in list_node: self.__thisLibraryTreeView.insert(f1, "end", text=i) # create library folder f2 = self.__thisLibraryTreeView.insert("", "end", iid="Library Node", text="Library") self.__thisLibraryTreeView.insert(f2, "end", text="test_func1") self.__thisLibraryTreeView.insert(f2, "end", text="test_func2") self.__thisLibraryTreeView.insert(f2, "end", text="open_chrome") self.__thisLibraryTreeView.insert(f2, "end", text="open_gmail") return def __addNode(self): self.__thisActionListBox.insert( END, self.__thisLibraryTreeView.item( self.__thisLibraryTreeView.focus())['text']) self.__addActionToScript( self.__thisLibraryTreeView.item( self.__thisLibraryTreeView.focus())['text']) return def __addActionToScript(self, type): if type == "assign": self.__thisVariableList.__adduniqueitem__( variable.Variable("driver", "", "")) self.__thisVariableList.__adduniqueitem__( variable.Variable("url", "", "http://gmail.com")) # self.__thisScript.__additem__(assnode.AssignNode("", "")) elif type == "if-else": self.__thisScript.__additem__(ifnode.IfNode("", "", "")) elif type == "node-base": self.__thisScript.__additem__(nodebase.NodeBase("", "test_func1")) elif type == "test_func1": self.__thisScript.__additem__( nodebase.NodeBase("node-base1", "test_func1")) elif type == "test_func2": self.__thisScript.__additem__( nodebase.NodeBase("node-base2", "test_func2")) elif type == "open_chrome": self.__thisScript.__additem__( nodebase.NodeBase("node-base1", "open_chrome")) elif type == "open_gmail": self.__thisScript.__additem__( nodebase.NodeBase("node-base2", "open_gmail")) elif type == "message-box": self.__thisScript.__additem__( nodebase.NodeBase("node-base2", "message_box")) return def __deleteNode(self): self.__thisActionListBox.delete(ANCHOR) return def __showAbout(self): showinfo("pyRPA", "*****@*****.**") return def __openFile(self): self.__file = askopenfilename(defaultextension=".txt", filetypes=[("All Files", "*.*"), ("Text Documents", "*.txt")]) if self.__file == "": # no file to open self.__file = None else: # Try to open the file # set the window title self.__root.title(os.path.basename(self.__file) + " - Notepad") # self.__thisTextArea.delete(1.0,END) file = open(self.__file, "r") # self.__thisTextArea.insert(1.0,file.read()) file.close() def __newFile(self): self.__root.title("new file - pyRPA") self.__file = None self.__thisActionListBox.delete(0, END) self.__thisScript.__del__() self.__thisVariableList.__del__() print(self.__thisVariableList.__getleng__()) self.__thisScript = script.Script() self.__thisVariableList = variablelist.VariableList() self.__thisLibraryTreeView.item("Main Node", open=True) self.__thisLibraryTreeView.item("Library Node", open=True) # self.__thisTextArea.delete(1.0,END) def __saveFile(self): if self.__file == None: # Save as new file self.__file = asksaveasfilename(initialfile='Untitled.txt', defaultextension=".txt", filetypes=[("All Files", "*.*"), ("Text Documents", "*.txt")]) if self.__file == "": self.__file = None else: # Try to save the file file = open(self.__file, "w") file.close() # Change the window title self.__root.title(os.path.basename(self.__file) + " - Notepad") else: file = open(self.__file, "w") file.write(self.__thisTextArea.get(1.0, END)) file.close() def __cut(self): # self.__thisTextArea.event_generate("<<Cut>>") pass def __copy(self): # self.__thisTextArea.event_generate("<<Copy>>") pass def __paste(self): # self.__thisTextArea.event_generate("<<Paste>>") pass def __runScript(self): self.__thisScript.__run__() pass def __openEditor(self): pass def run(self): # Run main application self.__root.mainloop()