def add_item(self, url):
     #sprawdzenie po rozszerzeniu czy to filmik czy zdjecie
     url =str(url)
     file_type=url.split(".")
     file_type = (file_type[len(file_type)-1],"")
     
     if not(self.item_lists_exist):
         self.photo_list=ItemList()
         self.video_list=ItemList()
         self.photo_sublist = ItemList()
         self.item_lists_exist=True
         self.photo_types=set(self.photo_types.split())
         self.video_types=set(self.video_types.split()) 
         
     if self.video_types.intersection(file_type):
         print("this is a video")
         self.video_list.append_item(Item(url,self.listWidget_2 , "video_icon.jpg")) 
            
     elif self.photo_types.intersection(file_type):
         print("this is a photo")
         Dzialania_na_zdjeciach.zdejmij_kompresje(url)
         self.photo_list.append_item(Item(url,self.listWidget))
     else:
         print("The " , file_type, " extension is not supported")
         print("Supported extensions: ", self.photo_types, " and ", self.video_types)
Ejemplo n.º 2
0
    def initUI(self):
        if self.mainWindow:
            self.setAcceptDrops(True)
            self.setWindowTitle('Sistre')

            openAction = QtGui.QAction('Open', self)
            openAction.triggered.connect(self.showFileDialog)
            exitAction = QtGui.QAction('Exit', self)
            exitAction.triggered.connect(QtGui.qApp.quit)

            filemenu = self.menuBar().addMenu('File')
            filemenu.addAction(openAction)
            filemenu.addSeparator()
            filemenu.addAction(exitAction)

            self.parameterDialog = Parameter(self)
            parameterAction = QtGui.QAction('Parameter', self)
            parameterAction.triggered.connect(self.showParameterDialog)

            viewmenu = self.menuBar().addMenu('View')
            viewmenu.addAction(parameterAction)

            createGrpFromSelAction = QtGui.QAction('Create from selection',
                                                   self)
            createGrpFromSelAction.triggered.connect(
                self.createGroupFromSelection)
            createGrpDialogAction = QtGui.QAction('Create...', self)
            createGrpDialogAction.triggered.connect(self.showCreateGroupDialog)

            groupmenu = self.menuBar().addMenu('Group')
            groupmenu.addAction(createGrpFromSelAction)
            groupmenu.addAction(createGrpDialogAction)

        self.glRenderArea = GLRenderArea(self)
        self.centralTab = QtGui.QTabWidget()
        self.centralTab.addTab(self.glRenderArea, '3D View')
        self.centralTab.addTab(QtGui.QWidget(), '2D View')

        self.timerBar = TimerBar(self)

        self.leftLayout = QtGui.QVBoxLayout()
        self.leftLayout.addWidget(self.centralTab)
        self.leftLayout.addWidget(self.timerBar)

        self.itemList = ItemList(self)
        self.itemList.itemListPick.connect(self.glRenderArea.itemListPick)
        self.itemList.itemConfigChanged.connect(
            self.glRenderArea.itemConfigChanged)
        # self.itemList.itemConfigChanged.connect(self.graphRenderArea.itemConfigChanged)

        self.centralLayout = QtGui.QHBoxLayout()
        self.centralLayout.addLayout(self.leftLayout)
        self.centralLayout.addWidget(self.itemList)

        self.centralWidget = QtGui.QWidget()
        self.centralWidget.setLayout(self.centralLayout)

        self.setCentralWidget(self.centralWidget)
        self.show()
Ejemplo n.º 3
0
def submit():
    import base64
    from datetime import datetime
    import pickle
    from flask import render_template, request, make_response
    from ItemList import ItemList

    user = get_user_data()
    item = request.form["item"]

    if user.has_submitted(item):
        return render_template("duplicate.html")

    result = ItemList.check_item(item)

    if result is None:
        template = render_template("bad.html")
    else:
        prize = result[0]
        count = result[1]
        user.add_prize(item, prize, count)
        template = render_template("good.html", prize = prize, count = count)

    response = make_response(template)
    response.set_cookie("data", value=base64.b64encode(pickle.dumps(user)))
    return response
Ejemplo n.º 4
0
	def initUI(self):		
		if self.mainWindow:
			self.setAcceptDrops(True)
			self.setWindowTitle('Sistre')
		
			openAction = QtGui.QAction('Open', self)
			openAction.triggered.connect(self.showFileDialog)
			exitAction = QtGui.QAction('Exit', self)
			exitAction.triggered.connect(QtGui.qApp.quit)
		
			filemenu = self.menuBar().addMenu('File')
			filemenu.addAction(openAction)
			filemenu.addSeparator()
			filemenu.addAction(exitAction)
			
			self.parameterDialog = Parameter(self)
			parameterAction = QtGui.QAction('Parameter', self)
			parameterAction.triggered.connect(self.showParameterDialog)
			
			viewmenu = self.menuBar().addMenu('View')
			viewmenu.addAction(parameterAction)
			
			createGrpFromSelAction = QtGui.QAction('Create from selection', self)
			createGrpFromSelAction.triggered.connect(self.createGroupFromSelection)
			createGrpDialogAction = QtGui.QAction('Create...', self)
			createGrpDialogAction.triggered.connect(self.showCreateGroupDialog)
			
			groupmenu = self.menuBar().addMenu('Group')
			groupmenu.addAction(createGrpFromSelAction)
			groupmenu.addAction(createGrpDialogAction)

		self.glRenderArea = GLRenderArea(self)
		self.centralTab = QtGui.QTabWidget()
		self.centralTab.addTab(self.glRenderArea, '3D View')
		self.centralTab.addTab(QtGui.QWidget(), '2D View')
		
		self.timerBar = TimerBar(self)
		
		self.leftLayout = QtGui.QVBoxLayout()
		self.leftLayout.addWidget(self.centralTab)
		self.leftLayout.addWidget(self.timerBar)
		
		self.itemList = ItemList(self)
		self.itemList.itemListPick.connect(self.glRenderArea.itemListPick)
		self.itemList.itemConfigChanged.connect(self.glRenderArea.itemConfigChanged)
		# self.itemList.itemConfigChanged.connect(self.graphRenderArea.itemConfigChanged)
		
		self.centralLayout = QtGui.QHBoxLayout()
		self.centralLayout.addLayout(self.leftLayout)
		self.centralLayout.addWidget(self.itemList)
		
		self.centralWidget = QtGui.QWidget()
		self.centralWidget.setLayout(self.centralLayout)
		
		self.setCentralWidget(self.centralWidget)
		self.show()
Ejemplo n.º 5
0
class Screen(QtGui.QMainWindow):


	def __init__(self, data, mainWindow = False):
		super(Screen, self).__init__()
		
		self.data = data
		self.mainWindow = mainWindow
		
		if self.mainWindow:
			pass
			# print 'mainWindow'
			# self.data.loadData('.', 'Repro_geste_standard_assis_Trial1.c3d')
			# self.screenList = []
		else:
			pass
			# print 'new sub window'
		
		self.initUI()

		
	def initUI(self):		
		if self.mainWindow:
			self.setAcceptDrops(True)
			self.setWindowTitle('Sistre')
		
			openAction = QtGui.QAction('Open', self)
			openAction.triggered.connect(self.showFileDialog)
			exitAction = QtGui.QAction('Exit', self)
			exitAction.triggered.connect(QtGui.qApp.quit)
		
			filemenu = self.menuBar().addMenu('File')
			filemenu.addAction(openAction)
			filemenu.addSeparator()
			filemenu.addAction(exitAction)
			
			self.parameterDialog = Parameter(self)
			parameterAction = QtGui.QAction('Parameter', self)
			parameterAction.triggered.connect(self.showParameterDialog)
			
			viewmenu = self.menuBar().addMenu('View')
			viewmenu.addAction(parameterAction)
			
			createGrpFromSelAction = QtGui.QAction('Create from selection', self)
			createGrpFromSelAction.triggered.connect(self.createGroupFromSelection)
			createGrpDialogAction = QtGui.QAction('Create...', self)
			createGrpDialogAction.triggered.connect(self.showCreateGroupDialog)
			
			groupmenu = self.menuBar().addMenu('Group')
			groupmenu.addAction(createGrpFromSelAction)
			groupmenu.addAction(createGrpDialogAction)

		self.glRenderArea = GLRenderArea(self)
		self.centralTab = QtGui.QTabWidget()
		self.centralTab.addTab(self.glRenderArea, '3D View')
		self.centralTab.addTab(QtGui.QWidget(), '2D View')
		
		self.timerBar = TimerBar(self)
		
		self.leftLayout = QtGui.QVBoxLayout()
		self.leftLayout.addWidget(self.centralTab)
		self.leftLayout.addWidget(self.timerBar)
		
		self.itemList = ItemList(self)
		self.itemList.itemListPick.connect(self.glRenderArea.itemListPick)
		self.itemList.itemConfigChanged.connect(self.glRenderArea.itemConfigChanged)
		# self.itemList.itemConfigChanged.connect(self.graphRenderArea.itemConfigChanged)
		
		self.centralLayout = QtGui.QHBoxLayout()
		self.centralLayout.addLayout(self.leftLayout)
		self.centralLayout.addWidget(self.itemList)
		
		self.centralWidget = QtGui.QWidget()
		self.centralWidget.setLayout(self.centralLayout)
		
		self.setCentralWidget(self.centralWidget)
		self.show()
		
		
	def showFileDialog(self):
		fileDialog = QtGui.QFileDialog(parent = self, caption = 'Open video file')
		if fileDialog.exec_() == QtGui.QDialog.Accepted:
			self.data.loadData(str(fileDialog.selectedFiles()[0]))
			
			
	def showParameterDialog(self):
		self.parameterDialog.show()
			
			
	def showCreateGroupDialog(self):
		pass
		
		
	def createGroupFromSelection(self):
		newGroup = self.data.createGroupFromSelection(list(self.glRenderArea.selectedMarkers))
		self.glRenderArea.addGroup(newGroup)
			
			
	def dragEnterEvent(self, event):
		if event.mimeData().hasUrls():
			event.accept()
		else:
			event.ignore()

			
	def dropEvent(self, event):
		if len(event.mimeData().urls()) > 0:
			url = event.mimeData().urls()[0]
			path = url.toLocalFile().toLocal8Bit().data()
			self.data.loadData(path)
		else:
			event.ignore()
			
			
	def dataLoaded(self):
		self.setWindowTitle(self.data.dataPath + self.data.dataFile + ' - Sistre')
	
		self.glRenderArea.clearItemConfig()
	
		self.timerBar.setPauseButtonChecked(self.data.paused)
		self.timerBar.setMaximum(self.data.totalFrame)
		self.timerBar.setValue(self.data.currentFrame)
		
		self.itemList.setItemData(self.data)
		
		
	def dataPauseToggled(self):
		self.timerBar.setPauseButtonChecked(self.data.paused)
		
		
	def dataFrameUpdated(self):
		self.timerBar.setValue(self.data.currentFrame)
Ejemplo n.º 6
0
class Screen(QtGui.QMainWindow):
    def __init__(self, data, mainWindow=False):
        super(Screen, self).__init__()

        self.data = data
        self.mainWindow = mainWindow

        if self.mainWindow:
            pass
            # print 'mainWindow'
            # self.data.loadData('.', 'Repro_geste_standard_assis_Trial1.c3d')
            # self.screenList = []
        else:
            pass
            # print 'new sub window'

        self.initUI()

    def initUI(self):
        if self.mainWindow:
            self.setAcceptDrops(True)
            self.setWindowTitle('Sistre')

            openAction = QtGui.QAction('Open', self)
            openAction.triggered.connect(self.showFileDialog)
            exitAction = QtGui.QAction('Exit', self)
            exitAction.triggered.connect(QtGui.qApp.quit)

            filemenu = self.menuBar().addMenu('File')
            filemenu.addAction(openAction)
            filemenu.addSeparator()
            filemenu.addAction(exitAction)

            self.parameterDialog = Parameter(self)
            parameterAction = QtGui.QAction('Parameter', self)
            parameterAction.triggered.connect(self.showParameterDialog)

            viewmenu = self.menuBar().addMenu('View')
            viewmenu.addAction(parameterAction)

            createGrpFromSelAction = QtGui.QAction('Create from selection',
                                                   self)
            createGrpFromSelAction.triggered.connect(
                self.createGroupFromSelection)
            createGrpDialogAction = QtGui.QAction('Create...', self)
            createGrpDialogAction.triggered.connect(self.showCreateGroupDialog)

            groupmenu = self.menuBar().addMenu('Group')
            groupmenu.addAction(createGrpFromSelAction)
            groupmenu.addAction(createGrpDialogAction)

        self.glRenderArea = GLRenderArea(self)
        self.centralTab = QtGui.QTabWidget()
        self.centralTab.addTab(self.glRenderArea, '3D View')
        self.centralTab.addTab(QtGui.QWidget(), '2D View')

        self.timerBar = TimerBar(self)

        self.leftLayout = QtGui.QVBoxLayout()
        self.leftLayout.addWidget(self.centralTab)
        self.leftLayout.addWidget(self.timerBar)

        self.itemList = ItemList(self)
        self.itemList.itemListPick.connect(self.glRenderArea.itemListPick)
        self.itemList.itemConfigChanged.connect(
            self.glRenderArea.itemConfigChanged)
        # self.itemList.itemConfigChanged.connect(self.graphRenderArea.itemConfigChanged)

        self.centralLayout = QtGui.QHBoxLayout()
        self.centralLayout.addLayout(self.leftLayout)
        self.centralLayout.addWidget(self.itemList)

        self.centralWidget = QtGui.QWidget()
        self.centralWidget.setLayout(self.centralLayout)

        self.setCentralWidget(self.centralWidget)
        self.show()

    def showFileDialog(self):
        fileDialog = QtGui.QFileDialog(parent=self, caption='Open video file')
        if fileDialog.exec_() == QtGui.QDialog.Accepted:
            self.data.loadData(str(fileDialog.selectedFiles()[0]))

    def showParameterDialog(self):
        self.parameterDialog.show()

    def showCreateGroupDialog(self):
        pass

    def createGroupFromSelection(self):
        newGroup = self.data.createGroupFromSelection(
            list(self.glRenderArea.selectedMarkers))
        self.glRenderArea.addGroup(newGroup)

    def dragEnterEvent(self, event):
        if event.mimeData().hasUrls():
            event.accept()
        else:
            event.ignore()

    def dropEvent(self, event):
        if len(event.mimeData().urls()) > 0:
            url = event.mimeData().urls()[0]
            path = url.toLocalFile().toLocal8Bit().data()
            self.data.loadData(path)
        else:
            event.ignore()

    def dataLoaded(self):
        self.setWindowTitle(self.data.dataPath + self.data.dataFile +
                            ' - Sistre')

        self.glRenderArea.clearItemConfig()

        self.timerBar.setPauseButtonChecked(self.data.paused)
        self.timerBar.setMaximum(self.data.totalFrame)
        self.timerBar.setValue(self.data.currentFrame)

        self.itemList.setItemData(self.data)

    def dataPauseToggled(self):
        self.timerBar.setPauseButtonChecked(self.data.paused)

    def dataFrameUpdated(self):
        self.timerBar.setValue(self.data.currentFrame)
class ListWidgetFunctions():
    item_lists_exist=False
    photo_types="jpg gif bmp png jpeg Jpeg Gif tif tiff Bmp Jpg JPG GIF PNG JPEG TIF rgb pbm ppm rast xbm"
    video_types="avi AVI mpeg MPEG mp4 MP4"

	# zaladowanie zdjec i video z folderu
    def add_item(self, url):
        #sprawdzenie po rozszerzeniu czy to filmik czy zdjecie
        url =str(url)
        file_type=url.split(".")
        file_type = (file_type[len(file_type)-1],"")
        
        if not(self.item_lists_exist):
            self.photo_list=ItemList()
            self.video_list=ItemList()
            self.photo_sublist = ItemList()
            self.item_lists_exist=True
            self.photo_types=set(self.photo_types.split())
            self.video_types=set(self.video_types.split()) 
            
        if self.video_types.intersection(file_type):
            print("this is a video")
            self.video_list.append_item(Item(url,self.listWidget_2 , "video_icon.jpg")) 
               
        elif self.photo_types.intersection(file_type):
            print("this is a photo")
            Dzialania_na_zdjeciach.zdejmij_kompresje(url)
            self.photo_list.append_item(Item(url,self.listWidget))
        else:
            print("The " , file_type, " extension is not supported")
            print("Supported extensions: ", self.photo_types, " and ", self.video_types)
            
    
    def get_current_item(self,list_widget,item_list):
		print("get current item")
		return item_list.get_item(list_widget.currentRow())
		
    def get_current_item_index(self,list_widget):
		print("get current item index")
		return list_widget.currentRow()
		
    def get_current_item_url(self,list_widget, item_list):
        return self.get_current_item(list_widget, item_list).url
		
    def remove_item(self,list_widget, itemlist, index):
        print("remove item", index)
        if index>-1:
            list_widget.takeItem(index)
            itemlist.delete_item(index)
        
    def clear_photo_lists(self):
        print("clear_photo_lists")
        a = self.photo_list.len()
        arr=range(a)
        for i in arr:
			a=a-1
			self.remove_item(self.listWidget, self.photo_list,a)
			
    def clear_photo_sublist(self):
        print("clear_photo_SUBlists")
        a = self.photo_sublist.len()
        arr=range(a)
        for i in arr:
			a=a-1
			self.remove_item(self.listWidget_3, self.photo_sublist,a)			
			
		
    def clear_video_lists(self):
        print("clear_video_lists")
        a= self.video_list.len()
        arr= range(a)
        print(arr , a)
        for i in arr:
			a=a-1
			self.remove_item(self.listWidget_2, self.video_list,a)
        
    def remove_all_items(self):
        print("remove all items")
        a = self.photo_list.len()
        arr=range(a)
        for i in arr:
			a=a-1
			self.remove_item(self.listWidget, self.photo_list,a)
			
        a= self.video_list.len()
        arr= range(a)
        print(arr , a)
        for i in arr:
			a=a-1
			self.remove_item(self.listWidget_2, self.video_list,a)
			
    def zmien_rozszerzenie_w_adresie(self,url ,rozszerzenie):
		print "zmien rozszerzenie w adresie"
		return(url.split(".")[0]+"."+rozszerzenie)
		
    def znajdz_czas_pomiaru(self,url_zdjecia):
        #file_name=str(self.listWidget_3.currentItem().text())
        arr = url_zdjecia.split("\\")
        a= len(arr)-1
               
        file_name= arr[a]
        time=file_name.split(".")[0]  #z adresu url wyluskuje numer zdjecia
        folder_path=url_zdjecia.rstrip(file_name)
        try:
            f=open((folder_path+"frame_info.txt"))
            f.readline()
            interval = f.readline().strip()
            f.close()
            time=eval(interval)* eval(time)
        except:
			time = str(time+"*unknown_interval")
        return str(time)