Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def conf():
os.environ['HOME'] = tempfile.mkdtemp()
yield config.Config()
shutil.rmtree(os.environ['HOME'])
def conf(self):
if not hasattr(self, '_conf'):
self._conf = config.Config()
return self._conf
def set_icon(self):
if 'win32' in sys.platform:
icon_ = os.path.join(config.CODEPATH, 'res', 'icon3.ico')
self.root.iconbitmap(default=icon_)
elif 'linux' in sys.platform:
img_ = tk.Image('photo', file=os.path.join(config.CODEPATH, 'res', 'icon3.png'))
self.root.tk.call('wm', 'iconphoto', self.root._w, img_)
'control': ttk.OptionMenu,
'values': [12, 20],
},
'theme': {
'label': 'Theme',
'tooltip': 'Style appearance of the user interface',
'var': tk.StringVar,
'control': ttk.OptionMenu,
'values': self.style_ttk.theme_names(),
},
'time_zone': {
'label': 'Time zone offset',
'tooltip': 'UTC offset for reporting time and date stamps',
'var': tk.StringVar,
'control': ttk.OptionMenu,
'values': config.TIME_ZONES,
},
'date_format': {
'label': 'Date format',
'tooltip': 'Format in which the time and date are reported',
'var': tk.StringVar,
'control': ttk.Entry,
},
'custom_header': {
'label': 'Custom header',
'tooltip': 'Custom header information for HTML reports. Use HTML tags for customization.',
'var': tk.StringVar,
'control': ttk.Entry,
},
'custom_footer': {
'label': 'Custom footer',
'tooltip': 'Custom footer information for HTML reports. Use HTML tags for customization.',
self.root = tk.Toplevel(root, takefocus=True)
self.root.protocol("WM_TAKE_FOCUS")
self.root.transient(root)
self.root.bind('', lambda e: self.root.destroy())
else:
self.root = tk.Tk()
self.root.bind('', self.quit_app)
self.root.protocol("WM_DELETE_WINDOW", self.quit_app)
self.root.title(title)
self.root.resizable(False, False)
self.set_icon()
self.root.grid_columnconfigure(0, weight=1)
self.root.grid_rowconfigure(0, weight=1)
self.NWES = (tk.N, tk.W, tk.E, tk.S)
self.WE = (tk.W, tk.E)
logo_ = os.path.join(config.CODEPATH, 'res', 'logo.gif')
self.img_logo = tk.PhotoImage(master=root, file=logo_)
self.style_ttk = ttk.Style()
self.conf = config.Config()
if self.conf('theme'):
self.style_ttk.theme_use(self.conf('theme'))
self.FontMono = self.get_monospace_font()
self.FontStatus = font.Font(size='10', weight='bold')
self.FontTitle = font.Font(size='12', weight='bold')
self.FontInfo = font.Font(size='9', slant='italic')
self.OUTPUT = tk.StringVar()
self.mainframe = ttk.Frame(self.root, padding=5, relief='groove')
self.mainframe.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
# self.mainframe.grid(row=0, column=0, sticky=self.NWES)