<s> import os <EOL> import csv <EOL> from PySide . QtGui import * <EOL> from PySide . QtCore import * <EOL> from ui_EventList import Ui_EventList <EOL> from EventWindow import EventWindow <EOL> class EventListWindow ( QDialog , Ui_EventList ) : <EOL> def __init__ ( self , parent ) : <EOL> super ( EventListWindow , self ) . __init__ ( parent ) <EOL> self . rent = parent <EOL> self . setupUi ( self ) <EOL> self . assignWidgets ( ) <EOL> self . csvList = [ ] <EOL> def updateGUI ( self ) : <EOL> self . eventTree . setSortingEnabled ( False ) <EOL> self . eventTree . clear ( ) <EOL> del self . csvList [ : ] <EOL> self . csvList . append ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> for eventId in self . rent . filteredEventData : <EOL> eventItem = TreeWidgetItem ( self . eventTree ) <EOL> eventItem . setText ( <NUM_LIT:0> , eventId ) <EOL> eventItem . setText ( <NUM_LIT:1> , unicode ( self . rent . eventData [ eventId ] [ "<STR_LIT>" ] ) ) <EOL> eventItem . setText ( <NUM_LIT:2> , unicode ( self . rent . eventData [ eventId ] [ "<STR_LIT>" ] ) ) <EOL> eventItem . setText ( <NUM_LIT:3> , unicode ( self . rent . eventData [ eventId ] [ "<STR_LIT>" ] ) ) <EOL> eventItem . setText ( <NUM_LIT:4> , unicode ( self . rent . eventData [ eventId ] [ "<STR_LIT>" ] ) ) <EOL> eventItem . setText ( <NUM_LIT:5> , unicode ( self . rent . eventData [ eventId ] [ "<STR_LIT>" ] ) ) <EOL> eventItem . setText ( <NUM_LIT:6> , unicode ( self . rent . eventData [ eventId ] [ "<STR_LIT>" ] ) ) <EOL> eventItem . setText ( <NUM_LIT:7> , unicode ( self . rent . eventData [ eventId ] [ "<STR_LIT>" ] ) ) <EOL> eventItem . setText ( <NUM_LIT:8> , unicode ( self . rent . eventData [ eventId ] [ "<STR_LIT>" ] ) ) <EOL> eventItem . setText ( <NUM_LIT:9> , unicode ( self . rent . eventData [ eventId ] [ "<STR_LIT>" ] ) ) <EOL> eventItem . setText ( <NUM_LIT:10> , unicode ( self . rent . eventData [ eventId ] [ "<STR_LIT>" ] ) ) <EOL> self . eventTree . addTopLevelItem ( eventItem ) <EOL> self . csvList . append ( [ eventId , self . rent . eventData [ eventId ] [ "<STR_LIT>" ] , self . rent . eventData [ eventId ] [ "<STR_LIT>" ] , <EOL> self . rent . eventData [ eventId ] [ "<STR_LIT>" ] , self . rent . eventData [ eventId ] [ "<STR_LIT>" ] , <EOL> self . rent . eventData [ eventId ] [ "<STR_LIT>" ] , self . rent . eventData [ eventId ] [ "<STR_LIT>" ] , <EOL> self . rent . eventData [ eventId ] [ "<STR_LIT>" ] , self . rent . eventData [ eventId ] [ "<STR_LIT>" ] , <EOL> self . rent . eventData [ eventId ] [ "<STR_LIT>" ] , self . rent . eventData [ eventId ] [ "<STR_LIT>" ] ] ) <EOL> self . eventTree . setSortingEnabled ( True ) <EOL> for i in range ( <NUM_LIT:11> ) : <EOL> self . eventTree . resizeColumnToContents ( i ) <EOL> def cancelPressed ( self ) : <EOL> self . hide ( ) <EOL> def eventSelected ( self , ourEvent , ourColumn ) : <EOL> eventId = ourEvent . text ( <NUM_LIT:0> ) <EOL> if not self . rent . eventData [ eventId ] [ "<STR_LIT>" ] : <EOL> self . rent . eventData [ eventId ] [ "<STR_LIT>" ] = EventWindow ( self . rent , eventId ) <EOL> self . rent . eventData [ eventId ] [ "<STR_LIT>" ] . show ( ) <EOL> def exportStatsPressed ( self ) : <EOL> filename = QFileDialog . getSaveFileName ( self , '<STR_LIT>' , os . getenv ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> if filename [ <NUM_LIT:0> ] : <EOL> with open ( filename [ <NUM_LIT:0> ] , "<STR_LIT:wb>" ) as f : <EOL> writer = csv . writer ( f ) <EOL> writer . writerows ( self . csvList ) <EOL> self . rent . messageBox ( "<STR_LIT>" ) <EOL> def assignWidgets ( self ) : <EOL> self . adjustFiltersButton . clicked . connect ( lambda : self . rent . filtersWindow . show ( ) ) <EOL> self . cancelButton . clicked . connect ( self . cancelPressed ) <EOL> self . exportStatsButton . clicked . connect ( self . exportStatsPressed ) <EOL> self . eventTree . itemDoubleClicked . connect ( self . eventSelected ) <EOL> class TreeWidgetItem ( QTreeWidgetItem ) : <EOL> def __init__ ( self , parent = None ) : <EOL> QTreeWidgetItem . __init__ ( self , parent ) <EOL> def __lt__ ( self , otherItem ) : <EOL> column = self . treeWidget ( ) . sortColumn ( ) <EOL> try : <EOL> return float ( self . text ( column ) ) > float ( otherItem . text ( column ) ) <EOL> except ValueError : <EOL> return self . text ( column ) > otherItem . text ( column ) </s>
