0

I want to create a MenuItem that an Entry shows on this to user can enter value to the entry widget. This procedure is easy to implement but after showing this Entry it cant get cursor and user cant input text to it, help me to do it please. i used pygtk 2.0 .

#!/usr/bin/env python
import gtk

win = gtk.Window()
win.connect( "destroy", gtk.main_quit )

menubar = gtk.MenuBar()
popup = gtk.Menu()
root_menu = gtk.MenuItem("root")
menu_item = gtk.MenuItem()
field =  gtk.Entry()

win.add( menubar )
menubar.add( root_menu )
root_menu.set_submenu( popup )
popup.append( menu_item )
menu_item.add( field )

win.show_all()    
print field.get_can_focus(), field.get_editable()

gtk.main()
Cœur
  • 37,241
  • 25
  • 195
  • 267
M.javid
  • 6,387
  • 3
  • 41
  • 56

3 Answers3

2

Here is a post announcing that what you are trying to do might be included in GTK 3.4; but I don't know where to find the current state of that code.

ptomato
  • 56,175
  • 13
  • 112
  • 165
0

Here is a great menubar example -- just copy it and put it menubar_test.py then change the permissions chmod 755 menubar_test.py

Hope this helps you!

M.javid
  • 6,387
  • 3
  • 41
  • 56
palbakulich
  • 261
  • 1
  • 2
  • 10
  • thanks but my problem is not how to using menu in gtk, my problem is that Entry widget after adding to a menu item cant get value . – M.javid Feb 12 '11 at 07:12
0

Using pygtk 2.0, I believe you want to use:

field.set_text("Here is my text in gtk.Entry widget")

field.get_text() retrieves the text that you just set above in gtk.Entry.

zx485
  • 28,498
  • 28
  • 50
  • 59
rise.riyo
  • 64
  • 5