def __init__(self, text = "", font = system_font, multiline = False, password = False, border = True, **kwds): ns_textfield = self._create_ns_textfield(editable = True, multiline = multiline, password = password, text = text, font = font, border = border) GTextField.__init__(self, _ns_view = ns_textfield, multiline = multiline, **kwds)
def __init__(self, font=application_font, lines=1, multiline=0, password=0, **kwds): self._multiline = multiline lm, tm, rm, bm = gtk_margins if multiline: gtk_textbuffer = gtk.TextBuffer() gtk_textview = gtk.TextView(gtk_textbuffer) #gtk_textview.set_accepts_tab(False) #^%$#^%$!!! moves the focus itself. #self._gtk_connect(gtk_textview, 'key-press-event', self._gtk_key_press_event) self._gtk_connect(gtk_textbuffer, 'changed', self._gtk_changed) gtk_alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0) gtk_alignment.set_padding(tm, bm, lm, rm) gtk_alignment.add(gtk_textview) gtk_box = gtk.EventBox() gtk_box.add(gtk_alignment) gtk_box.modify_bg(gtk.STATE_NORMAL, gtk_textview.style.base[gtk.STATE_NORMAL]) gtk_frame = gtk.Frame() gtk_frame.set_shadow_type(gtk.SHADOW_IN) gtk_frame.add(gtk_box) self._gtk_textbuffer = gtk_textbuffer gtk_text_widget = gtk_textview gtk_outer = gtk_frame else: gtk_entry = gtk.Entry() #self._gtk_connect(gtk_entry, 'key-press-event', self._gtk_key_press_event) self._gtk_connect(gtk_entry, 'changed', self._gtk_changed) self._gtk_entry = gtk_entry gtk_text_widget = gtk_entry gtk_outer = gtk_entry self._gtk_text_widget = gtk_text_widget self._font = font gtk_text_widget.modify_font(font._pango_description) self._vertical_padding = tm + 2 * gtk_outer.style.ythickness + bm height = self._vertical_padding + lines * font.text_size("X")[1] gtk_outer.set_size_request(-1, height) self._password = password if password: if not multiline: self._gtk_entry.set_visibility(0) self._gtk_entry.set_invisible_char("*") else: raise ValueError( "The password option is not supported for multiline" " TextFields on this platform") gtk_outer.show_all() GTextField.__init__(self, _gtk_outer=gtk_outer, _gtk_title=gtk_text_widget, _gtk_focus=gtk_text_widget, _gtk_input=gtk_text_widget, multiline=multiline, **kwds)
def __init__(self, font=application_font, lines=1, multiline=0, password=0, **kwds): self._multiline = multiline lm, tm, rm, bm = gtk_margins if multiline: gtk_textbuffer = gtk.TextBuffer() gtk_textview = gtk.TextView(gtk_textbuffer) # gtk_textview.set_accepts_tab(False) #^%$#^%$!!! moves the focus itself. # self._gtk_connect(gtk_textview, 'key-press-event', self._gtk_key_press_event) gtk_alignment = gtk.Alignment(0.5, 0.5, 1.0, 1.0) gtk_alignment.set_padding(tm, bm, lm, rm) gtk_alignment.add(gtk_textview) gtk_box = gtk.EventBox() gtk_box.add(gtk_alignment) gtk_box.modify_bg(gtk.STATE_NORMAL, gtk_textview.style.base[gtk.STATE_NORMAL]) gtk_frame = gtk.Frame() gtk_frame.set_shadow_type(gtk.SHADOW_IN) gtk_frame.add(gtk_box) self._gtk_textbuffer = gtk_textbuffer gtk_text_widget = gtk_textview gtk_outer = gtk_frame else: gtk_entry = gtk.Entry() # self._gtk_connect(gtk_entry, 'key-press-event', self._gtk_key_press_event) self._gtk_entry = gtk_entry gtk_text_widget = gtk_entry gtk_outer = gtk_entry self._font = font gtk_text_widget.modify_font(font._pango_description) self._vertical_padding = tm + 2 * gtk_outer.style.ythickness + bm height = self._vertical_padding + lines * font.text_size("X")[1] gtk_outer.set_size_request(-1, height) self._password = password if password: if not multiline: self._gtk_entry.set_visibility(0) self._gtk_entry.set_invisible_char("*") else: raise ValueError("The password option is not supported for multiline" " TextFields on this platform") gtk_outer.show_all() GTextField.__init__( self, _gtk_outer=gtk_outer, _gtk_title=gtk_text_widget, _gtk_focus=gtk_text_widget, _gtk_input=gtk_text_widget, multiline=multiline, **kwds )
def __init__(self, **kwds): font = kwds.setdefault('font', application_font) multiline = kwds.setdefault('multiline', False) password = kwds.pop('password', False) self._multiline = multiline self._password = password h = self._calc_height(font) flags = win_style if multiline: flags |= win_multiline_style if password: flags |= win_password_style win = ui.CreateEdit() # Border can get lost if we construct it with too big a rect, so # we set the initial size after creation. win.CreateWindow(flags, (0, 0, 0, 0), win_none, 0) win.ModifyStyleEx(0, win_ex_style) win.MoveWindow((0, 0, 100, h)) GTextField.__init__(self, _win=win, **kwds)
def __init__(self, **kwds): font = kwds.setdefault("font", application_font) multiline = kwds.setdefault("multiline", False) password = kwds.pop("password", False) self._multiline = multiline self._password = password h = self._calc_height(font) flags = win_style if multiline: flags |= win_multiline_style if password: flags |= win_password_style win = ui.CreateEdit() # Border can get lost if we construct it with too big a rect, so # we set the initial size after creation. win.CreateWindow(flags, (0, 0, 0, 0), win_none, 0) win.ModifyStyleEx(0, win_ex_style) win.MoveWindow((0, 0, 100, h)) GTextField.__init__(self, _win=win, **kwds)
def __init__(self, font=application_font, lines=1, multiline=0, password=0, **kwds): self._multiline = multiline lm, tm, rm, bm = gtk_margins if multiline: gtk_textbuffer = Gtk.TextBuffer() gtk_textview = Gtk.TextView.new_with_buffer(gtk_textbuffer) gtk_textview.set_margin_left(lm) gtk_textview.set_margin_top(tm) gtk_textview.set_margin_right(rm) gtk_textview.set_margin_bottom(bm) gtk_box = Gtk.EventBox() gtk_box.add(gtk_textview) state = Gtk.StateFlags.NORMAL #bg = gtk_textview.get_style_context().get_background_color(state) # doesn't work #print "TextField: bg =", bg ### bg = gtk_white gtk_box.override_background_color(state, bg) gtk_outer = PyGUI_GtkFrame() gtk_outer.add(gtk_box) # gtk_alignment = Gtk.Alignment.new(0.5, 0.5, 1.0, 1.0) # gtk_alignment.set_padding(tm, bm, lm, rm) # gtk_alignment.add(gtk_textview) # gtk_box = Gtk.EventBox() # gtk_box.add(gtk_alignment) # gtk_box.modify_bg(Gtk.StateType.NORMAL, # gtk_textview.get_style().base[Gtk.StateType.NORMAL]) # gtk_frame = Gtk.Frame() # gtk_frame.set_shadow_type(Gtk.ShadowType.IN) # gtk_frame.add(gtk_box) self._gtk_textbuffer = gtk_textbuffer gtk_text_widget = gtk_textview # gtk_outer = gtk_frame else: gtk_entry = Gtk.Entry() self._gtk_entry = gtk_entry gtk_text_widget = gtk_entry gtk_outer = gtk_entry self._font = font #gtk_text_widget.modify_font(font._pango_description) gtk_text_widget.override_font(font._pango_description) #border_size = gtk_outer.get_style().ythickness # not working #print "TextFields: border size =", border_size ### self._vertical_padding = tm + 2 * gtk_border_size + bm #line_height = font.text_size("X")[1] line_height = font.line_height height = self._vertical_padding + lines * line_height gtk_outer.set_size_request(-1, height) self._password = password if password: if not multiline: self._gtk_entry.set_visibility(0) else: raise ValueError( "The password option is not supported for multiline" " TextFields on this platform") gtk_outer.show_all() GTextField.__init__(self, _gtk_outer=gtk_outer, _gtk_title=gtk_text_widget, _gtk_focus=gtk_text_widget, _gtk_input=gtk_text_widget, multiline=multiline, **kwds)
def __init__(self, font = application_font, lines = 1, multiline = 0, password = 0, **kwds): self._multiline = multiline lm, tm, rm, bm = gtk_margins if multiline: gtk_textbuffer = Gtk.TextBuffer() gtk_textview = Gtk.TextView.new_with_buffer(gtk_textbuffer) gtk_textview.set_margin_left(lm) gtk_textview.set_margin_top(tm) gtk_textview.set_margin_right(rm) gtk_textview.set_margin_bottom(bm) gtk_box = Gtk.EventBox() gtk_box.add(gtk_textview) state = Gtk.StateFlags.NORMAL #bg = gtk_textview.get_style_context().get_background_color(state) # doesn't work #print "TextField: bg =", bg ### bg = gtk_white gtk_box.override_background_color(state, bg) gtk_outer = PyGUI_GtkFrame() gtk_outer.add(gtk_box) # gtk_alignment = Gtk.Alignment.new(0.5, 0.5, 1.0, 1.0) # gtk_alignment.set_padding(tm, bm, lm, rm) # gtk_alignment.add(gtk_textview) # gtk_box = Gtk.EventBox() # gtk_box.add(gtk_alignment) # gtk_box.modify_bg(Gtk.StateType.NORMAL, # gtk_textview.get_style().base[Gtk.StateType.NORMAL]) # gtk_frame = Gtk.Frame() # gtk_frame.set_shadow_type(Gtk.ShadowType.IN) # gtk_frame.add(gtk_box) self._gtk_textbuffer = gtk_textbuffer gtk_text_widget = gtk_textview # gtk_outer = gtk_frame else: gtk_entry = Gtk.Entry() self._gtk_entry = gtk_entry gtk_text_widget = gtk_entry gtk_outer = gtk_entry self._font = font #gtk_text_widget.modify_font(font._pango_description) gtk_text_widget.override_font(font._pango_description) #border_size = gtk_outer.get_style().ythickness # not working #print "TextFields: border size =", border_size ### self._vertical_padding = tm + 2 * gtk_border_size + bm #line_height = font.text_size("X")[1] line_height = font.line_height height = self._vertical_padding + lines * line_height gtk_outer.set_size_request(-1, height) self._password = password if password: if not multiline: self._gtk_entry.set_visibility(0) else: raise ValueError("The password option is not supported for multiline" " TextFields on this platform") gtk_outer.show_all() GTextField.__init__(self, _gtk_outer = gtk_outer, _gtk_title = gtk_text_widget, _gtk_focus = gtk_text_widget, _gtk_input = gtk_text_widget, multiline = multiline, **kwds)