The procedure for requesting AWR support has changed. Please read all about the new AWR product support process.
Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Code Block
titleGraphEnable Full Code
import tkinter as tk
from tkinter import ttk
import pyawr.mwoffice as mwo #Import pyawr interface to AWRDE

class GraphEnable(object):
    def __init__(self):
    def GraphEnable_ui(self, GraphName_list):
        self.root = tk.Tk()      #Setup main (root) application window
        self.root.title('Enable Graphs')
        self.root.geometry('400x200+400+700')  #width * height + x-position + y-position
        #Allow window to expand if window is resized
        self.root.columnconfigure(0, weight=1)
        self.root.rowconfigure(0, weight=1)
        #Add frame. Padding is margin around the frame (left, top, right, bottom)
        mainframe = ttk.Frame(self.root, padding='10 10 10 10', borderwidth=10, relief='ridge')
        mainframe.grid(column=0, row=0) #Set grid for placing widgets
        #Add Widgets
        #Add label
        ttk.Label(mainframe, text='Select Graph').grid(column=0, row=0, pady=2, sticky=(tk.W))
        #Add Combo Box
        self.GraphComboBox = ttk.Combobox(mainframe, values=GraphName_list, width=30)
        self.GraphComboBox.grid(column=0, row=2, pady=5, sticky=tk.W)
        self.GraphComboBox.bind('<<ComboboxSelected>>', self.ComboBoxHandler)
        self.GraphSelected = GraphName_list[0]
        self.var = tk.IntVar()
        self.EnableButton = tk.Radiobutton(mainframe, text='Enable Measurements',\
                 variable=self.var, value=0, command=self.RadioButtonHandler)
        self.EnableButton.grid(column=0, row=3, sticky=tk.W)
        self.DisableButton = tk.Radiobutton(mainframe, text='Disable Measurements',\
                 variable=self.var, value=1, command=self.RadioButtonHandler)
        self.DisableButton.grid(column=0, row=4,  sticky=tk.W) 
        self.RadioButtonSelected = 0
        #OK Button. Event driven: call method ok_button() on click
        ttk.Button(mainframe, text='OK', command=self.ok_button).grid(column=2, row=4, padx=10, pady=10)        
        #Start the window
        self.root.mainloop()   #Start the window. Create infinite do-loop
        self.root.quit()       #Close the window 
        return self.GraphSelected, self.RadioButtonSelected
    def ComboBoxHandler(self, event=None):
        self.GraphSelected = self.GraphComboBox.get()
    def RadioButtonHandler(self):
        self.RadioButtonSelected = self.var.get()
    def ok_button(self):#--------------------------------------------
        self.root.destroy()    #Exit the infinite do-loop: root.mainloop()
graph_ui = GraphEnable()
version_str = '16.0' #Set specific version of AWRDE
awrde = mwo.CMWOffice(version=version_str)  #Establish link to AWRDE
project = awrde.Project #Create "project" variable as a convenience item
#Get graphs names from project
GraphName_list = list()
for graph in project.Graphs:

GraphSelected, RadioButtonSelected = graph_ui.GraphEnable_ui(GraphName_list)
graph = project.Graphs(GraphSelected)
for meas in graph.Measurements:
    if RadioButtonSelected == 0: #Eanbled
        meas.Enabled = True
    elif RadioButtonSelected == 1:
        meas.Enabled = False
print('Done . . . ')



PyQt enables more functionality and an enhanced look and feel over what Tkinter can provide. Optionally, and highly recommended, the Qt Designer tool can be used to graphically design your dialog box much in the same way as the UserDialog editor in SAX Basic. Qt Designer creates an XML file that is then converted into Python code using a Windows cmd instruction. This Python code, stored as a Python module, can then be imported into your Python script the same as any standard module. See Qt Designer link for installation and this link on how to operate Qt Designer.