Native gui: ongoing work, cables and fuses
This commit is contained in:
+20
-3
@@ -6,6 +6,7 @@ Generic view object
|
||||
SPDX-License-Identifier: WTFPL
|
||||
"""
|
||||
import os
|
||||
import locale
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import GLib, Gtk, Gdk
|
||||
@@ -26,10 +27,26 @@ class View:
|
||||
self.topwidget = builder.get_object("topobject")
|
||||
gtkutils.init_named_controls(self, builder)
|
||||
|
||||
def format_date(self, dateval):
|
||||
if dateval is None:
|
||||
def format_int(self, ival, separator=True, suffix=None):
|
||||
if ival is None:
|
||||
return ''
|
||||
return dateval.strftime(self.context.datefmt)
|
||||
formatted = locale.format_string("%d", ival, separator)
|
||||
if suffix:
|
||||
formatted += f"\u00A0{suffix}"
|
||||
return formatted
|
||||
|
||||
def format_float(self, fval, digits=2, grouping=True, suffix=None):
|
||||
if fval is None:
|
||||
return ''
|
||||
formatted = locale.format_string(f"%.{digits}f", fval, grouping)
|
||||
if suffix:
|
||||
formatted += f"\u00A0{suffix}"
|
||||
return formatted
|
||||
|
||||
def format_date(self, dval):
|
||||
if dval is None:
|
||||
return ''
|
||||
return dval.strftime(self.context.datefmt)
|
||||
|
||||
def on_textview_keypress(self, widget, event):
|
||||
# Generic limit length function
|
||||
|
||||
Reference in New Issue
Block a user