Skip to content

Commit bed3544

Browse files
committed
Fix opacity setting
1 parent 50f15c6 commit bed3544

2 files changed

Lines changed: 5 additions & 49 deletions

File tree

mynoteslib/config/config.py

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
from tkinter import font
2525
from tkinter import Toplevel, StringVar, Menu, Text, BooleanVar
2626
from tkinter.ttk import Label, Radiobutton, Button, Style, Separator, \
27-
Notebook, Combobox, Frame, Menubutton, Checkbutton
27+
Notebook, Frame, Menubutton, Checkbutton
2828

2929
from mynoteslib.messagebox import showinfo
30-
from mynoteslib.autocomplete import AutoCompleteCombobox
3130
from mynoteslib.constants import COLORS, SYMBOLS, LANGUAGES, REV_LANGUAGES, \
3231
TOOLKITS, AUTOCORRECT, CONFIG, save_config, add_trace
3332
from mynoteslib.autoscrollbar import AutoScrollbar
@@ -117,7 +116,7 @@ def __init__(self, master):
117116
command=self.ok).grid(row=1, column=0, padx=4, pady=10, sticky="e")
118117
Button(okcancel_frame, text=_("Cancel"),
119118
command=self.destroy).grid(row=1, column=1, padx=4, pady=10, sticky="w")
120-
119+
121120
def _init_general(self):
122121
general_settings = Frame(self.notebook, padding=4)
123122
general_settings.columnconfigure(0, weight=1)
@@ -317,20 +316,6 @@ def cleanup(self):
317316
self.master.cleanup()
318317
showinfo(_('Information'), _('Unused local data have been cleaned up.'))
319318

320-
def validate_font_size(self, combo, d, ch, V):
321-
"""Validation of the size entry content."""
322-
if d == '1':
323-
l = [i for i in self.sizes if i[:len(ch)] == ch]
324-
if l:
325-
i = self.sizes.index(l[0])
326-
combo.current(i)
327-
index = combo.index("insert")
328-
combo.selection_range(index + 1, "end")
329-
combo.icursor(index + 1)
330-
return ch.isdigit()
331-
else:
332-
return True
333-
334319
def ok(self):
335320
"""Validate configuration."""
336321
# --- splash supported
@@ -343,9 +328,6 @@ def ok(self):
343328
style = "{weight},{slant}".format(**title_font)
344329
style = style + ',underline' * title_font['underline']
345330

346-
# --- opacity
347-
opacity = "%i" % self.opacity.get()
348-
349331
# --- language
350332
language = REV_LANGUAGES[self.lang.get()]
351333

@@ -360,7 +342,7 @@ def ok(self):
360342
CONFIG.set("General", "default_category",
361343
self.category_settings.default_category.get().lower())
362344
CONFIG.set("General", "language", language)
363-
CONFIG.set("General", "opacity", opacity)
345+
CONFIG.set("General", "opacity", str(self.opacity.get()))
364346
CONFIG.set("General", "position", self.position.get())
365347
CONFIG.set("General", "buttons_position", self.titlebar_disposition.get())
366348
CONFIG.set("General", "date_in_title", str(self.date_in_title.get()))
@@ -416,32 +398,6 @@ def change_gui(self):
416398
_("The GUI Toolkit setting will take effect after restarting the application"),
417399
parent=self)
418400

419-
def update_preview(self, event=None):
420-
"""Update font preview."""
421-
family = self.font_family.get()
422-
size = self.font_size.get()
423-
self.sample.configure(font="%s %s" % (family.replace(" ", "\ "), size))
424-
self.update_mono_preview()
425-
426-
def update_mono_preview(self, event=None):
427-
"""Update mono font preview."""
428-
family = self.mono_family.get()
429-
size = self.font_size.get()
430-
self.sample_mono.configure(font="%s %s" % (family.replace(" ", "\ "), size))
431-
432-
def update_preview_title(self, event=None):
433-
"""Update title font preview."""
434-
family = self.fonttitle_family.get()
435-
size = self.fonttitle_size.get()
436-
config = "%s %s" % (family.replace(" ", "\ "), size)
437-
if self.is_bold.instate(("selected",)):
438-
config += " bold"
439-
if self.is_italic.instate(("selected",)):
440-
config += " italic"
441-
if self.is_underlined.instate(("selected",)):
442-
config += " underline"
443-
self.sampletitle.configure(font=config)
444-
445401
def display_label(self, value):
446402
self.opacity_label.configure(text=" {val} %".format(val=int(float(value))))
447403

mynoteslib/config/opacity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626

2727

2828
class OpacityFrame(ttk.Frame):
29-
def __init__(self, master=None, value=0.85, style='TLabel', **kw):
29+
def __init__(self, master=None, value=85, style='TLabel', **kw):
3030
ttk.Frame.__init__(self, master, **kw)
3131

3232
self.columnconfigure(1, weight=1)
3333
self.opacity_scale = ScaleEntry(self, orient="horizontal", scalewidth=300,
3434
from_=0, to=100, entryscalepad=10,
35-
value=int(value * 100))
35+
value=int(value))
3636
ttk.Label(self, style=style,
3737
text=_("Opacity")).grid(row=0, column=0, sticky="w", padx=(0, 4), pady=4)
3838
self.opacity_scale.grid(row=0, column=1, padx=4, pady=4)

0 commit comments

Comments
 (0)