Commit 99535d41 authored by LorenzoMonti's avatar LorenzoMonti
Browse files

Restyle UI with Azure-ttk-theme

parent f59e221b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
{
    "": "",
    "gpib": "GPIB::18::INSTR",
    "remote_eth": "TCPIP0::localhost::49153::SOCKET",
    "local_eth": "TCPIP0::<ip>::INSTR"
+5 −5
Original line number Diff line number Diff line
@@ -163,8 +163,8 @@ def clear_background(self):
        UI function
        
        """
        self.Message1.configure(background="#d9d9d9", font=("Helvetica", 10))
        self.Message2.configure(background="#d9d9d9", font=("Helvetica", 10))
        self.Message3.configure(background="#d9d9d9", font=("Helvetica", 10))
        self.Message4.configure(background="#d9d9d9", font=("Helvetica", 10))
        self.Message5.configure(background="#d9d9d9", font=("Helvetica", 10))
 No newline at end of file
        self.Message1.configure(background="#ffffff", font=("Helvetica", 10))
        self.Message2.configure(background="#ffffff", font=("Helvetica", 10))
        self.Message3.configure(background="#ffffff", font=("Helvetica", 10))
        self.Message4.configure(background="#ffffff", font=("Helvetica", 10))
        self.Message5.configure(background="#ffffff", font=("Helvetica", 10))
 No newline at end of file

src/azure.tcl

0 → 100755
+87 −0
Original line number Diff line number Diff line
# Copyright © 2021 rdbende <rdbende@gmail.com>

source theme/light.tcl
source theme/dark.tcl

option add *tearOff 0

proc set_theme {mode} {
	if {$mode == "dark"} {
		ttk::style theme use "azure-dark"

		array set colors {
            -fg             "#ffffff"
            -bg             "#333333"
            -disabledfg     "#ffffff"
            -disabledbg     "#737373"
            -selectfg       "#ffffff"
            -selectbg       "#007fff"
        }
        
        ttk::style configure . \
            -background $colors(-bg) \
            -foreground $colors(-fg) \
            -troughcolor $colors(-bg) \
            -focuscolor $colors(-selectbg) \
            -selectbackground $colors(-selectbg) \
            -selectforeground $colors(-selectfg) \
            -insertcolor $colors(-fg) \
            -insertwidth 1 \
            -fieldbackground $colors(-selectbg) \
            -font {"Segoe Ui" 10} \
            -borderwidth 1 \
            -relief flat

        tk_setPalette background [ttk::style lookup . -background] \
            foreground [ttk::style lookup . -foreground] \
            highlightColor [ttk::style lookup . -focuscolor] \
            selectBackground [ttk::style lookup . -selectbackground] \
            selectForeground [ttk::style lookup . -selectforeground] \
            activeBackground [ttk::style lookup . -selectbackground] \
            activeForeground [ttk::style lookup . -selectforeground]

        ttk::style map . -foreground [list disabled $colors(-disabledfg)]

        option add *font [ttk::style lookup . -font]
        option add *Menu.selectcolor $colors(-fg)
    
	} elseif {$mode == "light"} {
		ttk::style theme use "azure-light"

        array set colors {
            -fg             "#000000"
            -bg             "#ffffff"
            -disabledfg     "#737373"
            -disabledbg     "#ffffff"
            -selectfg       "#ffffff"
            -selectbg       "#007fff"
        }

		ttk::style configure . \
            -background $colors(-bg) \
            -foreground $colors(-fg) \
            -troughcolor $colors(-bg) \
            -focuscolor $colors(-selectbg) \
            -selectbackground $colors(-selectbg) \
            -selectforeground $colors(-selectfg) \
            -insertcolor $colors(-fg) \
            -insertwidth 1 \
            -fieldbackground $colors(-selectbg) \
            -font {"Segoe Ui" 10} \
            -borderwidth 1 \
            -relief flat

        tk_setPalette background [ttk::style lookup . -background] \
            foreground [ttk::style lookup . -foreground] \
            highlightColor [ttk::style lookup . -focuscolor] \
            selectBackground [ttk::style lookup . -selectbackground] \
            selectForeground [ttk::style lookup . -selectforeground] \
            activeBackground [ttk::style lookup . -selectbackground] \
            activeForeground [ttk::style lookup . -selectforeground]

        ttk::style map . -foreground [list disabled $colors(-disabledfg)]

        option add *font [ttk::style lookup . -font]
        option add *Menu.selectcolor $colors(-fg)
	}
}
+12 −22
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ from tkinter import Radiobutton
from tkinter.constants import DISABLED
from typing import Text
from matplotlib.pyplot import text
import ctypes

from numpy.lib.function_base import insert, select
import Anritsu_MS2830A as SPA
@@ -27,12 +28,17 @@ try:
except ImportError:
    import tkinter.ttk as ttk
    py3 = True

import gui_support

def vp_start_gui():
    '''Starting point when module is the main routine.'''
    global val, w, root
    root = tk.Tk()
    # Simply set the theme
    root.tk.call("source", "azure.tcl")
    root.tk.call("set_theme", "light")

    top = UserInterface (root)
    gui_support.init(root, top)
    root.mainloop()
@@ -46,6 +52,7 @@ def create_UserInterface(rt, *args, **kwargs):
    root = rt
    w = tk.Toplevel(root)
    top = UserInterface(w)
    ctypes.windll.shcore.SetProcessDpiAwareness(1)
    gui_support.init(w, top, *args, **kwargs)
    return (w, top)

@@ -58,24 +65,12 @@ class UserInterface:
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9' # X11 color: 'gray85'
        _ana1color = '#d9d9d9' # X11 color: 'gray85'
        _ana2color = '#ececec' # Closest X11 color: 'gray92'
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.',background=_bgcolor)
        self.style.configure('.',foreground=_fgcolor)
        self.style.configure('.',font="TkDefaultFont")
        self.style.map('.',background=
            [('selected', _compcolor), ('active',_ana2color)])

        top.geometry("600x736+308+141")
        top.minsize(1, 1)
        

        top.geometry("1600x800")
        top.minsize(200, 100)
        top.maxsize(3825, 2130)
        top.resizable(1,  1)
        top.resizable(1,  2)
        top.title("Multifeed receiver measure")

        #############################
@@ -85,11 +80,6 @@ class UserInterface:
        config_file = Utils.read_config_file("../config/config_MS2830A.json")
        ##############################
        
        self.style.configure('TNotebook.Tab', background=_bgcolor)
        self.style.configure('TNotebook.Tab', foreground=_fgcolor)
        self.style.map('TNotebook.Tab', background=
            [('selected', _compcolor), ('active',_ana2color)])
        
        #############################
        # NOTEBOOK CREATION
        #############################
+0 −0

File moved.

Loading