Current location: Hot Scripts Forums » Programming Languages » Other Languages » TextView Problems


TextView Problems

Reply
  #1 (permalink)  
Old 01-07-07, 01:09 PM
spyke01 spyke01 is offline
Newbie Coder
 
Join Date: Aug 2005
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
TextView Problems

Im working on an inventory manager script, i had this function working fine until i changed a text field to a textview. The way it needs to function is that when i try and edit an item it will fill in the information from a list on the previous dialog box. Heres the code:

Code:
	def on_EditItem(self, widget):
		"""Called when the user wants to edit an item entry"""

		# Get the selection in the gtk.TreeView
		selection = self.itemView.get_selection()
		# Get the selection iter
		model, selection_iter = selection.get_selected()

		if (selection_iter):
			"""There is a selection, so now get the the value at column
			self.cItemObject, the Item Object"""
			item = self.itemList.get_value(selection_iter, self.cItemObject)
			# Create the item dialog, based off of the current selection
			itemDlg = itemDialog(item);
			result,newItem = itemDlg.run()

			if (result == gtk.RESPONSE_OK):
				"""The user clicked Ok, so let's save the changes back
				into the gtk.ListStore"""
				self.itemList.set(selection_iter
						, self.cItemObject, newItem
						, self.cItem, newItem.item
						, self.cDescription, newItem.description
						, self.cType, newItem.type
						, self.cQuanity, newItem.quanity)

class itemDialog:
	"""This class is used to show itemDlg"""

	def __init__(self, item=None):
		"""Initialize the class.
		item - a Item object"""

		#setup the glade file
		self.gladefile = "inventory-manager.glade"
		#setup the item that we will return
		if (item):
			#They have passed an item object
			self.item = item
		else:
			#Just use a blank item
			self.item = Item()

	def run(self):
		"""This function will show the itemDlg"""

		#load the dialog from the glade file
		self.wTree = gtk.glade.XML(self.gladefile, "itemDlg")
		#Get the actual dialog widget
		self.dlg = self.wTree.get_widget("itemDlg")
		#Get all of the Entry Widgets and set their text
		self.enItem = self.wTree.get_widget("enItem")
		self.enItem.set_text(self.item.item)

		"""New Code"""
		self.textbuffer = gtk.TextBuffer(None)
		self.enDescription = gtk.TextView()
		self.enDescription.set_buffer(self.textbuffer)
		self.enDescription.insert_at_cursor(self.item.description)

		"""Old Code"""
		"""self.enDescription = self.wTree.get_widget("enDescription")"""
		"""self.enDescription.insert_at_cursor(self.item.description)"""

		self.enType = self.wTree.get_widget("enType")
		self.enType.set_text(self.item.type)
		self.enQuanity = self.wTree.get_widget("enQuanity")
		self.enQuanity.set_text(self.item.quanity)

		#run the dialog and store the response
		self.result = self.dlg.run()
		#get the value of the entry fields
		self.item.item = self.enItem.get_text()
		self.item.description = self.enDescription.get_text()
		self.item.type = self.enType.get_text()
		self.item.quanity = self.enQuanity.get_text()

		#we are done with the dialog, destory it
		self.dlg.destroy()

		#return the result and the item
		return self.result,self.item
The section with Old Code as the title is what it was with the text area, the New Code section is what i tried after the switch, the error i get is this:
Quote:
Traceback (most recent call last):
File "pyitem.py", line 125, in on_AddItem
result,newItem = itemDlg.run()
File "pyitem.py", line 306, in run
self.enDescription.insert(0, self.item.description)
AttributeError: 'gtk.TextView' object has no attribute 'insert'
Any help guys?
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
IE problems with encoding and displaying pages kittenesque HTML/XHTML/XML 1 10-21-06 04:59 PM
Password Problems in VB6 iceiceady Visual Basic 6 03-28-06 03:17 PM
Code Problems smoove HTML/XHTML/XML 1 03-09-05 10:09 AM
2 spacing/alignment problems Arowana HTML/XHTML/XML 0 01-07-04 11:58 AM


All times are GMT -5. The time now is 03:40 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.