remove border of a gtk.button

前端 未结 3 968
广开言路
广开言路 2021-01-21 13:13

I want to remove the border of the gtk.button, but i Don\'t know how to do it.

I tried with :

button = gtk.Button()
button.set_style(\"inner-border\",0)
         


        
相关标签:
3条回答
  • 2021-01-21 13:27
    label_box = Gtk::HBox.new(false, 0) 
    label = Gtk::Label.new('Page1') 
    label_box.pack_start(label, false, false, 0) 
    
    btn = Gtk::Button.new 
    btn.relief = Gtk::RELIEF_NONE 
    btn.focus_on_click = false 
    style = btn.modifier_style 
    style.xthickness = 0 
    style.ythickness = 0 
    btn.modify_style(style) 
    btn.set_tooltip_text("Close page1") 
    wim,him = Gtk::IconSize.lookup(Gtk::IconSize::MENU) 
    btn.set_size_request(wim+2,him+2) 
    btn.signal_connect('clicked') do 
      $notebook.remove_page($notebook.children.index(treeview)) 
      store.clear 
      label_box.destroy 
      treeview.destroy 
    end 
    
    image = Gtk::Image.new(Gtk::Stock::CLOSE, Gtk::IconSize::MENU) 
    btn.add(image) 
    
    align = Gtk::Alignment.new(1.0, 0.0, 0.0, 0.0) 
    align.add(btn) 
    label_box.pack_start(align, false, false, 0) 
    
    label_box.spacing = 3 
    label_box.show_all 
    
    page = $notebook.append_page(treeview, label_box) 
    treeview.show_all 
    $notebook.page = $notebook.n_pages-1 
    
    0 讨论(0)
  • 2021-01-21 13:37

    Short version:

    import gtk
    window = gtk.Dialog()
    button = gtk.Button('Click Me')
    button.props.relief = gtk.RELIEF_NONE
    window.vbox.pack_start(button)
    window.show_all()
    window.run()
    
    0 讨论(0)
  • 2021-01-21 13:42

    Set the button's relief property:

    button.props.relief = gtk.RELIEF_NONE
    

    Full test program:

    import gtk
    
    window = gtk.Window ()
    box    = gtk.VButtonBox ()
    
    for k in range (10):
        button = gtk.Button ('button %d' % k)
        if k % 2 == 0:
            button.props.relief = gtk.RELIEF_NONE
    
        box.add (button)
    
    window.add (box)
    window.show_all ()
    
    gtk.main ()
    

    If this doesn't work for you, then your GTK+ theme doesn't support RELIEF_NONE.

    0 讨论(0)
提交回复
热议问题