File: RefDisplayDates.py

package info (click to toggle)
bibus 1.5.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 12,488 kB
  • sloc: python: 30,790; sql: 211; makefile: 158; xml: 10; sh: 3
file content (60 lines) | stat: -rw-r--r-- 1,894 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
# generated by wxGlade 0.5 on Wed Aug 22 22:23:34 2007 from /home/pmartino/Desktop/bibus-cvs/bibus/wxg/RefDisplayDates.wxg

import wx,time,BIB

class RefDisplay(wx.Panel):
	def __init__(self, *args, **kwds):
		# begin wxGlade: RefDisplay.__init__
		kwds["style"] = wx.TAB_TRAVERSAL
		wx.Panel.__init__(self, *args, **kwds)
		self.RefDisplay = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH)

		self.__set_properties()
		self.__do_layout()
		# end wxGlade
		self.bibframe = None	# we need the main bibus bibframe for callback and self.db

	def __set_properties(self):
		# begin wxGlade: RefDisplay.__set_properties
		pass
		# end wxGlade

	def __do_layout(self):
		# begin wxGlade: RefDisplay.__do_layout
		sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
		sizer_1.Add(self.RefDisplay, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
		self.SetSizer(sizer_1)
		sizer_1.Fit(self)
		# end wxGlade

	def Clear(self):
		self.RefDisplay.Clear()
		
	def resetFormat(self,format): # not used
		return

	def display(self,ref):
		"""Display the reference ref
		If ref = '' => clear the display
		"""
		self.Clear()
		if ref:
			creator,date,user_modif,date_modif = self.bibframe.db.getModifs(ref[0])
			datestr = time.strftime("%c",time.gmtime(date)).decode('utf-8')
			datemodifstr = time.strftime("%c",time.gmtime(date_modif)).decode('utf-8')
			if not date: datestr = _("Unknown")
			if not date_modif: datemodifstr = _("Unknown")
			#
			for key,text in ((_("Creator"),creator),(_("Date"),datestr),(_("Modified by"),user_modif),(_("Date"),datemodifstr)):
				self.RefDisplay.SetDefaultStyle(wx.TextAttr(BIB.KEY_COLOR))
				self.RefDisplay.AppendText("""%s: """ %key)
				self.RefDisplay.SetDefaultStyle(wx.TextAttr(BIB.TEXT_COLOR))
				self.RefDisplay.AppendText("""%s\n""" %text)
			self.RefDisplay.ShowPosition(0)

# end of class RefDisplay