def bn_browse_for(vip, k): Dialog = QWidget() Dialog.resize(50, 70) # *cs.RESIZE_BROWSE_DIALOG Dialog.move(100, 100) def _set_file_path(sk, file_extension): new_path = str(QFileDialog.getOpenFileName(Dialog, 'Open a file', os.sep, "*."+file_extension)) if new_path: vip.set(sk, {k : new_path}) # this is a le change, triggered from this bn action return new_path def _set_dir_path(sk): new_path = str(QFileDialog.getExistingDirectory(Dialog, 'Open a folder', os.sep, QFileDialog.ShowDirsOnly)) if new_path: vip.set(sk, {k : new_path}) # this is a le change, triggered from this bn action return new_path if k == 'FILE_PATH_session': new_path = _set_file_path('Session', "txt") if new_path: bn_load_session_to_vip(vip) elif k == 'DIR_PATH_results': _set_dir_path('Results') elif k in ['FILE_PATH_waveform_'+str(j) for j in range(4)]: _set_file_path('H3344_1', "csv") else: vip.GUI_feedback("!!! (bn_browse_for) A strange key was passed.") Dialog.close()
def run(self): w = QWidget() w.resize(250, 150) w.move(300, 300) w.setWindowTitle('Simple') w.show() while(self.ready): time.sleep(0.1)
''' Demo application showing PinMatrix widget in action ''' app = QApplication(sys.argv) matrix = PinMatrixWidget() def clicked(): print("PinMatrix value is", matrix.get_value()) print("Possible button combinations:", matrix.get_strength()) sys.exit() ok = QPushButton('OK') if QT_VERSION_STR >= '5': ok.clicked.connect(clicked) elif QT_VERSION_STR >= '4': QObject.connect(ok, SIGNAL('clicked()'), clicked) else: raise RuntimeError('Unsupported Qt version') vbox = QVBoxLayout() vbox.addWidget(matrix) vbox.addWidget(ok) w = QWidget() w.setLayout(vbox) w.move(100, 100) w.show() app.exec_()
class RemoconSub(QMainWindow): def __init__(self, parent, title, application, rocon_master_index="", rocon_master_name="", rocon_master_uri='localhost', host_name='localhost'): self.rocon_master_index = rocon_master_index self.rocon_master_uri = rocon_master_uri self.rocon_master_name = rocon_master_name self.host_name = host_name self._context = parent self.application = application super(RemoconSub, self).__init__(parent) self.initialised = False self._widget_app_list = QWidget() self._widget_role_list = QWidget() self.rocon_master_list = {} self.cur_selected_role = 0 self.app_list = {} self.cur_selected_app = None self.remocon_info = RemoconInfo(stop_app_postexec_fn=self._set_stop_app_button) path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../ui/applist.ui") uic.loadUi(path, self._widget_app_list) path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../ui/rolelist.ui") uic.loadUi(path, self._widget_role_list) utils.setup_home_dirs() self.rocon_master_list_cache_path = os.path.join(utils.get_settings_cache_home(), "rocon_master.cache") self.scripts_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../scripts/") #role list widget self._widget_role_list.role_list_widget.setIconSize(QSize(50, 50)) self._widget_role_list.role_list_widget.itemDoubleClicked.connect(self._select_role_list) self._widget_role_list.back_btn.pressed.connect(self._back_role_list) self._widget_role_list.refresh_btn.pressed.connect(self._refresh_role_list) #app list widget self._widget_app_list.app_list_widget.setIconSize(QSize(50, 50)) self._widget_app_list.app_list_widget.itemDoubleClicked.connect(self._start_app) self._widget_app_list.back_btn.pressed.connect(self._uninit_app_list) self._widget_app_list.app_list_widget.itemClicked.connect(self._select_app_list) # rocon master item click event self._widget_app_list.stop_app_btn.pressed.connect(self._stop_app) self._widget_app_list.refresh_btn.pressed.connect(self._refresh_app_list) self._widget_app_list.stop_app_btn.setDisabled(True) #init self._init() def _init(self): self._init_role_list() # Ugly Hack : our window manager is not graying out the button when an app closes itself down and the appropriate # callback (_set_stop_app_button) is fired. It does otherwise though so it looks like the window manager # is getting confused when the original program doesn't have the focus. # # Taking control of it ourselves works... self._widget_app_list.stop_app_btn.setStyleSheet(QString.fromUtf8("QPushButton:disabled { color: gray }")) self._widget_role_list.show() self.initialised = True ################################################################################################################ ##role list widget ################################################################################################################ def _init_role_list(self): if not self.remocon_info._connect(self.rocon_master_name, self.rocon_master_uri, self.host_name): return False self._refresh_role_list() return True def _uninit_role_list(self): print "[RemoconSub]_uninit_role_list" self.remocon_info._shutdown() self.cur_selected_role = 0 def _select_role_list(self, Item): print '_select_role_list: ' + Item.text() self.cur_selected_role = str(Item.text()) self.remocon_info._select_role(self.cur_selected_role) self._widget_app_list.show() self._widget_app_list.move(self._widget_role_list.pos()) self._widget_role_list.hide() self._init_app_list() def _back_role_list(self): self._uninit_role_list() execute_path = self.scripts_path + 'rocon_remocon' # command execute_path += " " + "'" + self.host_name + "'" # arg1 os.execv(self.scripts_path + 'rocon_remocon', ['', self.host_name]) print "Spawning: %s" % (execute_path) def _refresh_role_list(self): self._widget_role_list.role_list_widget.clear() role_list = self.remocon_info.get_role_list() #set list widget item (reverse order because we push them on the top) for role in reversed(role_list): self._widget_role_list.role_list_widget.insertItem(0, role) #setting the list font font = self._widget_role_list.role_list_widget.item(0).font() font.setPointSize(13) self._widget_role_list.role_list_widget.item(0).setFont(font) ################################################################################################################ ##app list widget ################################################################################################################ def _init_app_list(self): self._refresh_app_list() def _uninit_app_list(self): self._widget_role_list.show() self._widget_role_list.move(self._widget_app_list.pos()) self._widget_app_list.hide() def _refresh_app_list(self): self.app_list = {} self.app_list = self.remocon_info._get_app_list() self._widget_app_list.app_list_widget.clear() index = 0 for k in self.app_list.values(): k['index'] = index index = index + 1 self._widget_app_list.app_list_widget.insertItem(0, k['display_name']) #setting the list font font = self._widget_app_list.app_list_widget.item(0).font() font.setPointSize(13) self._widget_app_list.app_list_widget.item(0).setFont(font) #setting the icon app_icon = k['icon'] print("Icon: %s" % app_icon) if app_icon == "unknown.png": icon = QIcon(self.icon_paths['unknown']) self._widget_app_list.app_list_widget.item(0).setIcon(icon) elif len(app_icon): icon = QIcon(os.path.join(utils.get_icon_cache_home(), app_icon)) self._widget_app_list.app_list_widget.item(0).setIcon(icon) else: print self.rocon_master_name + ': No icon' pass def _select_app_list(self, Item): list_widget = Item.listWidget() cur_index = list_widget.count() - list_widget.currentRow() - 1 for k in self.app_list.values(): if(k['index'] == cur_index): self.cur_selected_app = k break self._widget_app_list.app_info.clear() info_text = "<html>" info_text += "<p>-------------------------------------------</p>" info_text += "<p><b>name: </b>" + self.cur_selected_app['name'] + "</p>" info_text += "<p><b> ---------------------</b>" + "</p>" info_text += "<p><b>compatibility: </b>" + self.cur_selected_app['compatibility'] + "</p>" info_text += "<p><b>display name: </b>" + self.cur_selected_app['display_name'] + "</p>" info_text += "<p><b>description: </b>" + self.cur_selected_app['description'] + "</p>" info_text += "<p><b>namespace: </b>" + self.cur_selected_app['namespace'] + "</p>" info_text += "<p><b>max: </b>" + str(self.cur_selected_app['max']) + "</p>" info_text += "<p><b> ---------------------</b>" + "</p>" info_text += "<p><b>remappings: </b>" + str(self.cur_selected_app['remappings']) + "</p>" info_text += "<p><b>parameters: </b>" + str(self.cur_selected_app['parameters']) + "</p>" info_text += "</html>" self._widget_app_list.app_info.appendHtml(info_text) self._set_stop_app_button() def _set_stop_app_button(self): ''' This can be used by the underlying listeners to check, and if needed, toggle the state of the stop app button whenever a running app terminates itself. ''' if not self.app_list: return try: if self.cur_selected_app["launch_list"]: console.logdebug("Remocon : enabling stop app button") self._widget_app_list.stop_app_btn.setDisabled(False) else: console.logdebug("Remocon : disabling stop app button") self._widget_app_list.stop_app_btn.setEnabled(False) except KeyError: pass # do nothing def _stop_app(self): print "Stop app: " + str(self.cur_selected_app['name']) if self.remocon_info._stop_app(self.cur_selected_app['hash']): self._set_stop_app_button() #self._widget_app_list.stop_app_btn.setDisabled(True) def _start_app(self): print "Start app: " + str(self.cur_selected_app['name']) if self.remocon_info._start_app(self.cur_selected_app['hash']): self._widget_app_list.stop_app_btn.setDisabled(False)
def get_value(self): return self.password.text() if __name__ == '__main__': ''' Demo application showing PinMatrix widget in action ''' a = QApplication(sys.argv) matrix = PinMatrixWidget() def clicked(): print "PinMatrix value is", matrix.get_value() print "Possible button combinations:", matrix.get_strength() sys.exit() ok = QPushButton('OK') QObject.connect(ok, SIGNAL('clicked()'), clicked) vbox = QVBoxLayout() vbox.addWidget(matrix) vbox.addWidget(ok) w = QWidget() w.setLayout(vbox) w.move(100, 100) w.show() a.exec_()
exit() #防止多开 ERROR_ALREADY_EXISTS = 183 sz_mutex = "test_mutex" hmutex = win32event.CreateMutex(None, pywintypes.FALSE, sz_mutex) if (win32api.GetLastError() == ERROR_ALREADY_EXISTS): win32api.CloseHandle(hmutex) button = QMessageBox.warning(w, "Alert", u'请勿重复开启!', QMessageBox.Ok) if button == QMessageBox.Ok: exit() #创建窗口 try: w.resize(250, 150) w.move(300, 300) w.setWindowTitle(u'By ddd') #窗口是否为置顶窗口 #w.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint) w.setWindowFlags(Qt.FramelessWindowHint) label_k = QLabel(u'您输入的关键词:') label_r = QLabel(u'匹配的最佳结果:') label_fi = QLabel(u'近五年影响因子:') label_i = QLabel(u'最新的影响因子:') l_keywords = QLabel(u'') l_results = QLabel(u'') l_if = QLabel(u'') l_fiveif = QLabel(u'') except: button = QMessageBox.warning(w, "Error", u'创建界面出错了!', QMessageBox.Ok)
class SystemTrayIcon(QtGui.QSystemTrayIcon): key1 = 0 def check_state(self): if self.w.windowState() == Qt.WindowMinimized: #print "Window is minimised. Restore it." try: #used try so that if user pressed other than the given key error will not be shown if keyboard.is_pressed('ctrl'): #if key 'q' is pressed #print"ctrl" if keyboard.is_pressed('k') and key==1: #print "key" key1 = 1 #self.w.setWindowState(Qt.WindowNoState) if keyboard.is_pressed('k') and key1 == 1: #print "key" key1 = 0 self.w.setWindowState(Qt.WindowNoState) except Exception as e: print "oops", e def updateIcon(self): self.w.show() #self.setIcon(QtGui.QIcon("Example2.ico")) def __init__(self, icon, parent=None): QtGui.QSystemTrayIcon.__init__(self, icon, parent) menu = QtGui.QMenu(parent) font = QtGui.QFont() font.setPointSize(12) #font.setBold(True) font.setWeight(75) changeicon = menu.addAction("Search") exitAction = menu.addAction("Exit") self.setContextMenu(menu) exitAction.triggered.connect(QtGui.qApp.quit) changeicon.triggered.connect(self.updateIcon) #the po up windows self.w = QWidget() x = 0 y = 0 ## try: ## user32 = ctypes.windll.user32 ## screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1) ## platforms=platform.system() ## if(platforms=="Windows"): ## x=1500 ## y=800 #### x=screensize[0]-300 #### y=screensize[1]-504 ## #print x,y ## else: ## x=1500 ## y=800 ## except Exception as e: ## print "exception",str(e) x = 1250 y = 200 #print x,y self.w.move(x, y) self.w.setWindowTitle('infomind_search_BOT') self.w.resize(650, 730) button = QPushButton('Search', self.w) button.move(560, 630) button.resize(80, 80) button2 = QtGui.QPushButton(self.w) icon2 = QIcon("images/if_08_171506.png") button2.setIcon(icon2) button2.move(520, 630) button2.resize(30, 30) #the borowser box browser = QTextBrowser(self.w) browser.setHtml(""" <!DOCTYPE html> <html> <style> body {g background-color: #ffffff; } </style> <body></body> </html> """) browser.move(20, 20) browser.resize(620, 600) textbox = QTextEdit(self.w) textbox.move(20, 630) ## textbox.wordWrapMode(True) textbox.resize(490, 80) paste_text = clipboard.paste() if (paste_text): paste_text = str(paste_text) #print "paste data",paste_text textbox.setText(paste_text) def rec_paste(): response = "" textString = QtCore.QString("""<style> .cll{background-color: #F4FD59 ;color: #000000;float:right;font-family: Trebuchet; font-size: 12px;margin-left:10px;font-weight: lighter;text-align: right; } .time{font-size: 11px ;vertical-align:bottom;color: #999999;} </style> <table><tr><td></br></br></td></tr></table> <table class="cll"> <tr> <td> Bot: Say something! </td> <td class="time" > <br>""" + time.strftime('%I:%M %p') + """</td> </tr> </table> <table><tr><td></br></br></td></tr></table>""") #print textString browser.append(textString) time.sleep(5) r = sr.Recognizer() with sr.Microphone() as source: r.adjust_for_ambient_noise(source, duration=1) print("Say something!") audio = r.listen(source, phrase_time_limit=5) # recognize speech using Sphinx/Google try: response = r.recognize_google(audio) print(" you said '" + response + "'") textString = QtCore.QString("""<style> .cll{background-color: #F4FD59 ;color: #000000;float:right;font-family: Trebuchet; font-size: 12px;margin-left:10px;font-weight: lighter;text-align: right; } .time{font-size: 11px ;vertical-align:bottom;color: #999999;} </style> <table><tr><td></br></br></td></tr></table> <table class="cll"> <tr> <td> Bot: I think you said """ + response + "'" + """ </td> <td class="time" > <br>""" + time.strftime('%I:%M %p') + """</td> </tr> </table> <table><tr><td></br></br></td></tr></table>""") #print textString browser.append(textString) except sr.UnknownValueError: print("Sorry could not understand audio") except sr.RequestError as e: print("Sorry error; {0}".format(e)) textbox.setText(response) def on_click(): #textbox.setText("Button clicked.") #print (dir(textbox)) text = unicode(textbox.toPlainText()) ## print text ## print len(text) ## print(not text) if (not (not text)): textString = QtCore.QString("""<style> .container {background-color: #ADFB42 ;width: 100%;color: #000000;float: left;margin-right:40px;font-family:Trebuchet;font-size: 15px ; font-weight: lighter;text-align: left; } .time{font-size: 11px ;vertical-align:bottom;color: #999999;} </style> <table class="container" style='overflow-x:scroll;height:100px;display:block;'> <tr> <td> Me : """ + text + """ <td class="time" ></br>""" + time.strftime('%I:%M %p') + """</td> </td> </tr> </table> <table><tr><td><br></td></tr></table>""") browser.append(textString) ## return_Res=answers(text) ## print return_Res ## print dir(return_Res) ## #return_Res="hello how can i help you today" infy = 0.000000 # equalant to - neg infinty ans_id = 0 text1 = text for index, row in df1.iterrows(): #print row['id'], row['Title'] text2 = row['Title'] vector1 = text_to_vector(text1) vector2 = text_to_vector(text2) cosine = get_cosine(vector1, vector2) if (cosine > infy): ans_id = row['id'] infy = cosine print ans_id a = (df1.loc[[ans_id - 1]]) return_Res = (a.iloc[0]['Resolution']) ## print dir(return_Res) return_Res2 = str(return_Res) #</code> return_Res2 = return_Res.replace('</code>', "") return_Res = return_Res2.replace("\n", " ") clipboard.copy(return_Res) if ('\n' in return_Res2): print "found" #print return_Res2 textString = QtCore.QString("""<style> .cll{background-color: #F4FD59 ;color: #000000;float:right;font-family: Trebuchet; font-size: 12px;margin-left:10px;font-weight: lighter;text-align: right; } .time{font-size: 11px ;vertical-align:bottom;color: #999999;} </style> <table style='overflow-x:auto;'><tr><td></br></br></td></tr></table> <table class="cll"> <tr> <td> Bot:""" + return_Res2 + """ </td> <td class="time" > <br>""" + time.strftime('%I:%M %p') + """</td> </tr> </table> <table><tr><td><br></br></td></tr></table>""") #print textString '<pre><code>print("Hello, World!")<br /></code></pre><br /><br />' return_Res2 = (str(return_Res2)) lst = [ "//>", "</pre>", "<code><pre>", "<code>", "<pre>", "</code>", "</>" ] ## return_Res2 = ' '.join(x for x in return_Res2.split(' ') if x not in lst) return_Res2 = return_Res2.replace('<br />', "\n", len(return_Res2)) return_Res2 = return_Res2.replace('</code>', "", len(return_Res2)) return_Res2 = return_Res2.replace('<code>', "", len(return_Res2)) return_Res2 = return_Res2.replace('</pre>', "", len(return_Res2)) return_Res2 = return_Res2.replace('<pre>', "", len(return_Res2)) ## return_Res2=return_Res.replace('</code>',"",len(return_Res2)) ## return_Res2=return_Res.replace('\n'," ",len(return_Res2)) ## return_Res2=return_Res.replace('<br /> '," ",len(return_Res2)) ## return_Res2=return_Res.replace("<br />"," ",len(return_Res2)) ## return_Res2=return_Res.replace('</pre>',"",len(return_Res2)) ## return_Res2=return_Res.replace('<pre>',"",len(return_Res2)) ## return_Res2=return_Res.replace('<code>',"",len(return_Res2)) ## return_Res2=re.sub('<br /> ', '', return_Res2) ## lst=["<br /> ","<br />","<br","//>","<br />","<code>","<pre>","</code>","</>"] ## ## return_Res2=' '.join(x for x in return_Res2.split(' ') if x not in lst) print return_Res2 print "##################################" browser.append(textString) else: textString = QtCore.QString("""<style> .cll{background-color: #F4FD59 ;color: #000000;font-family: Trebuchet; font-size: 15px;margin-left:60px;font-weight: lighter;text-align: right; } .time{font-size: 11px ;vertical-align:bottom;color: #999999;} </style> <table ><tr><td></br></br></td></tr></table> <table class="cll"> <tr> <td> Bot:Please enter search query </td> <td class="time" > """ + time.strftime('%I:%M %p') + """</td> </tr> </table> <table><tr><td><br><br></td></tr></table> <br><br>""") browser.append(textString) #print text button.clicked.connect(on_click) button2.clicked.connect(rec_paste) self.timer = QTimer() self.timer.setInterval(100) self.timer.timeout.connect(self.check_state) self.timer.start()
class ComponentSearchForm(): data_source = None related_mashups = None widget = None table = None add_btn = None graph_form = None highlighted_api = None highlighted_mashup = None categoryWindow = None dataSetListWdiget = None climateData = None def show_main_window(self): # Get datasets from server data = json.load(urllib2.urlopen(RECO_API_SERVER_ADDR + "/getAllDataSets/")) # self.climateData = self.loadClimateDataSet(data) self.climateData = self.parseServerData(data) self.graph_form = matplotlibWidget() if self.widget: self.widget.destroy() self.widget = None; self.widget = QWidget() self.widget.setMinimumSize(1000, 900) self.widget.setWindowTitle("Recommendation PlugIn") margin = 30 # Search Feature self.textboxLabel = QLabel(self.widget) self.textboxLabel.setText("Describe your goals:") self.textboxLabel.move(30, 20) self.textboxLabel.show self.textbox = QTextEdit(self.widget) self.textbox.move(30, 45) self.textbox.setFixedWidth(300) self.textbox.setFixedHeight(28) btn_api = QtGui.QPushButton("Recommend Services", self.widget) btn_api.move(30, 80) btn_mashup = QtGui.QPushButton("Recommend Workflows", self.widget) btn_mashup.move(230, 80) btn_api.clicked.connect(self.api_button_clicked) btn_mashup.clicked.connect(self.mashups_button_clicked) self.table = QTableView(self.widget) self.table.clicked.connect(self.table_clicked) self.table.setMinimumSize(600, 300) self.table.resizeColumnsToContents() self.table.move(30, 120) # Top Service self.textboxLabel = QLabel("Top Datasets (Usage)", self.widget) self.textboxLabel.move(650, 20) self.textboxLabel.show self.listWidget = QListWidget(self.widget) topDatasets = json.load(urllib2.urlopen(RECO_API_SERVER_ADDR + "/getTop10UsedDataset/")) for topDataset in topDatasets: id = int(topDataset["datasetID"]) item = QListWidgetItem("{} ({})".format(self.climateData[id]["name"], topDataset["usage"])) item.setData(Qt.UserRole,self.climateData[id]) self.listWidget.addItem(item) self.listWidget.move(650, 45) self.listWidget.resize(280, 380) self.listWidget.show() self.listWidget.clicked.connect(lambda: self.dataset_clicked(\ self.listWidget.currentItem().data(Qt.UserRole))) # Username input box and button for generating recommendations userTopOffset = 430 self.textboxLabel = QLabel("Enter username for dataset recommendations:", self.widget) self.textboxLabel.move(30, userTopOffset) self.textboxLabel.show() self.userTextbox = QTextEdit(self.widget) self.userTextbox.move(30, userTopOffset + 30) self.userTextbox.setFixedWidth(200) self.userTextbox.setFixedHeight(28) userBtn = QPushButton("Recommend Datasets", self.widget) userBtn.move(30 + self.userTextbox.width() + 10, userTopOffset + 30) #print RECO_API_SERVER_ADDR + "/getTop5RecommendationByUserName/" ## Jan.20 2016 ## Change the API names here by shenggu ## According to github.com/cmusv-sc/RecommendationAPIs ## userBtn.clicked.connect(lambda: self.getRecommendations(RECO_API_SERVER_ADDR + "/getTopKContentBasedCFRecommendedDatasetByUsername", self.recListFeature)) userBtn.clicked.connect(lambda: self.getRecommendations(RECO_API_SERVER_ADDR + "/getTopKItemBasedCFRecommendedDatasetByUsername", self.recListItem)) userBtn.clicked.connect(lambda: self.getRecommendations(RECO_API_SERVER_ADDR + "/getTopKUserBasedCFRecommendedDatasetByUsername", self.recListUser)) userBtn.show() # Test QlineEdit # self.userTextbox2 = QLineEdit(self.widget) # self.userTextbox.move(200, userTopOffset + 30) # self.userTextbox.setFixedWidth(200) # self.userTextbox.setFixedHeight(28) # Feature Recommendations recTopOffset = 500 self.textboxLabel = QLabel("Feature Recommendations", self.widget) self.textboxLabel.move(30, recTopOffset) self.textboxLabel.show() self.recListFeature = QListWidget(self.widget) self.recListFeature.move(30, recTopOffset + 30) self.recListFeature.resize(280, 250) self.recListFeature.show() # Item-based Recommendations self.textboxLabel = QLabel("Item-based Recommendations", self.widget) self.textboxLabel.move(340, recTopOffset) self.textboxLabel.show self.recListItem = QListWidget(self.widget) self.recListItem.move(340, recTopOffset + 30) self.recListItem.resize(280, 250) self.recListItem.show() # User-based Recommendations self.textboxLabel = QLabel("User-based Recommendations", self.widget) self.textboxLabel.move(650, recTopOffset) self.textboxLabel.show self.recListUser = QListWidget(self.widget) self.recListUser.move(650, recTopOffset + 30) self.recListUser.resize(280, 250) self.recListUser.show() # Categories categoryTopOffset = 300 self.textboxLabel = QLabel("Categories", self.widget) self.textboxLabel.move(30, recTopOffset + categoryTopOffset) self.textboxLabel.show button1 = QPushButton("By Agency", self.widget) button1.clicked.connect(lambda: self.listCategory_clicked("agency")) button1.move(30, recTopOffset + categoryTopOffset + 30) button1.show() button2 = QPushButton("By Instrument", self.widget) button2.clicked.connect(lambda: self.listCategory_clicked("instrument")) button2.move(margin + button1.width() + 20, recTopOffset + categoryTopOffset + 30) button2.show() button3 = QPushButton("By Data Source Input", self.widget) button3.clicked.connect(lambda: self.listCategory_clicked("input")) button3.move(margin + button1.width() + button2.width() + 40, recTopOffset + categoryTopOffset + 30) button3.show() # Show and move widget self.widget.move(QtGui.QApplication.desktop().screen().rect().center() - \ self.widget.rect().center()) self.widget.show() # Service and workflow recommendation self.add_btn = QPushButton("Add to Palette", self.widget) self.add_btn.clicked.connect(self.add_new_api) self.add_btn.hide() self.add_btn.setFixedWidth(160) self.add_btn.move(470, 20) self.recommendLabel = QLabel("Also Used", self.widget) self.recommendLabel.hide() self.recommendLabel.setFixedWidth(160) self.recommendLabel.move(470, 50) self.switch_btn_apis = QPushButton("Related Workflows", self.widget) self.switch_btn_apis.clicked.connect(self._show_related_apis) self.switch_btn_apis.hide() self.switch_btn_apis.setFixedWidth(160) self.switch_btn_apis.move(470, 80) self.switch_btn_mashups = QPushButton("Related Modules", self.widget) self.switch_btn_mashups.clicked.connect(self._show_related_mashups) self.switch_btn_mashups.hide() self.switch_btn_mashups.setFixedWidth(160) self.switch_btn_mashups.move(470, 80) def printMessage(self): print "testing" def __init__(self, parent=None): self.data_source = DataSource() def getRecommendations(self, url, listWidget): # http GET request username = str(self.userTextbox.toPlainText()) url = url + "?username=kzhang&top_num=5" # + username print url results = json.load(urllib2.urlopen(url)) # Update recommendation list listWidget.clear() for result in results: dataset = self.climateData[int(result["datasetID"])] item = QListWidgetItem(dataset["name"]) item.setData(Qt.UserRole, dataset) listWidget.addItem(item) listWidget.clicked.connect(lambda: self.dataset_clicked(\ listWidget.currentItem().data(Qt.UserRole))) def listCategory_clicked(self, category): self.categoryWindow = QWidget() c = self.categoryWindow c.setWindowTitle("Search dataset by category") c.setMinimumSize(600, 500) # Category list showing all posible options label1 = QLabel("Options by {0}:".format(category), c) label1.move(50, 20) label1.show() categoryListWidget = QListWidget(c) optionSet = set() for key in self.climateData: optionSet.add(self.climateData[key][category]) for option in sorted(list(optionSet)): item = QListWidgetItem(option) item.setData(Qt.UserRole, option) categoryListWidget.addItem(item) categoryListWidget.move(50, 50) categoryListWidget.resize(200, 400) categoryListWidget.show() categoryListWidget.clicked.connect(lambda: self.categoryItem_clicked(\ category, categoryListWidget.currentItem().data(Qt.UserRole))) # List showing all datasets associated with the selected option label2 = QLabel("Available Datasets:", c) label2.move(250, 20) label2.show() self.datasetListWidget = QListWidget(c) self.datasetListWidget.move(250, 50) self.datasetListWidget.resize(400, 400) self.datasetListWidget.show() c.move(QtGui.QApplication.desktop().screen().rect().center() - \ c.rect().center()) c.show() def categoryItem_clicked(self, category, option): self.datasetListWidget.clear() results = [] for key in self.climateData: if self.climateData[key][category] == option: results.append(self.climateData[key]) for result in sorted(results): item = QListWidgetItem(result["name"]) item.setData(Qt.UserRole,result) self.datasetListWidget.addItem(item) self.datasetListWidget.clicked.connect(lambda: self.dataset_clicked(\ self.datasetListWidget.currentItem().data(Qt.UserRole))); def dataset_clicked(self, data): # Initiate Table keyOrder = ["name", "agency", "instrument", "pvar", "var", "units", "grid", \ "webvar", "input", "start", "end"] sortedData = sorted(data.items(), key=lambda dataPair:keyOrder.index(dataPair[0])) self.topServiceTable = QTableWidget() t = self.topServiceTable t.setWindowTitle(data["name"]) t.resize(550, 400) t.setRowCount(len(data.keys())) t.setColumnCount(2) t.setColumnWidth(0, 100); t.setColumnWidth(1, 400); # Set label t.setHorizontalHeaderLabels(("Variable;Value").split(";")) # Set data for row, pair in enumerate(sortedData): t.setItem(row, 0, QTableWidgetItem(pair[0])) t.setItem(row, 1, QTableWidgetItem(pair[1])) t.move(QtGui.QApplication.desktop().screen().rect().topRight() - t.rect().topRight()) t.show() def table_clicked(self): """ Click the table, the graph form may change according to the selection. """ model = self.table.selectionModel() indexes = model.selectedIndexes() for index in indexes: row = index.row() # data = index.model().headerData(0,Qt.Horizontal).toString() data = index.model().headerData(0,Qt.Horizontal) newIndex = index.model().index(row, 0) if data == "API": api_id = get_api_full_name(newIndex.model().data(newIndex)) api = self.data_source.api_by_id(api_id) print api mashups = self.data_source.mashups_by_api(api) apis = [] for mashup in mashups: apis.extend(self.data_source.apis_by_mashup(mashup)) self.graph_form.draw_apis(apis, api, self.highlighted_api) else: mashup_id = get_mashup_full_name(newIndex.model().data(newIndex)) mashup = self.data_source.mashup_by_id(mashup_id) if not mashup: return apis = self.data_source.apis_by_mashup(mashup) mashups = [] if len(apis) > 0: mashups.extend(self.data_source.mashups_by_api(apis[0])) self.graph_form.draw_mashups(mashups, mashup, self.highlighted_mashup) return def _show_apis(self, apis, recommend=False): self.switch_btn_apis.hide() self.switch_btn_mashups.hide() self.recommendLabel.hide() row = 0 model = QStandardItemModel(len(apis), 4) model.setColumnCount(4) #QVariant(...) -> ... for api in apis: model.setData(model.index(row, 0), get_api_name(api)) model.setData(model.index(row, 1), api['protocols']) model.setData(model.index(row, 2), api['provider']) model.setData(model.index(row, 3), api['version']) row += 1 model.setHeaderData(0, Qt.Horizontal, "Service") # Replaced "Module" with "Service" model.setHeaderData(1, Qt.Horizontal, "Protocol") model.setHeaderData(2, Qt.Horizontal, "Provider") model.setHeaderData(3, Qt.Horizontal, "Version") self.table.setModel(model) self.table.resizeColumnsToContents() if recommend: self.recommendLabel.show() self.add_btn.show() def _show_mashups(self, mashups): self.switch_btn_apis.hide() self.switch_btn_mashups.hide() self.recommendLabel.hide() row = 0 model = QStandardItemModel(len(mashups), 4) model.setColumnCount(4) for mashup in mashups: model.setData(model.index(row, 0), get_mashup_name(mashup)) model.setData(model.index(row, 1), mashup['title']) model.setData(model.index(row, 2), mashup['self']) model.setData(model.index(row, 3), mashup['description']) row += 1 model.setHeaderData(0, Qt.Horizontal, "Workflow") model.setHeaderData(1, Qt.Horizontal, "Short Description") model.setHeaderData(2, Qt.Horizontal, "Provider") model.setHeaderData(3, Qt.Horizontal, "Detailed Info") self.table.setModel(model) self.table.resizeColumnsToContents() self.add_btn.show() def api_button_clicked(self): """ Trigger to search APIs """ self.graph_form.draw_api() self.graph_form.show() # Get user input from textbox apis = self.data_source.apis() key = str(self.textbox.toPlainText()) if key: self.api_search_button_clicked() else: self._show_apis(apis) def mashups_button_clicked(self): """ Trigger to search mashups """ self.graph_form.draw_mashup() self.graph_form.show() key = str(self.textbox.toPlainText()) print key print "button clicked" if key: self.mashup_search_button_clicked() else: self._show_mashups(self.data_source.mashups()) #Should probably refactor this into one method. def api_search_button_clicked(self): """ Search when keyword is present """ self.highlighted_api = None self.highlighted_mashup = None key = str(self.textbox.toPlainText()) if key != "": apis = self.data_source.search_api(key) self._show_apis(apis) def mashup_search_button_clicked(self): """ Search when keyword is present """ self.highlighted_api = None self.highlighted_mashup = None key = str(self.textbox.toPlainText()) if key != "": mashups = self.data_source.search_mashup(key) self._show_mashups(mashups) def add_new_api(self): """ Add new api to the modules package. """ apis = self.data_source.apis() model = self.table.selectionModel() indexes = model.selectedIndexes() for index in indexes: api = apis[index.row()] self._add_new_api(api) return def add_related_api(self): objs = [] for mashup in self.related_mashups: objs.append(mashup) for api in mashup["related_mashups"]: objs.append(api) model = self.table.selectionModel() indexes = model.selectedIndexes() for index in indexes: api = objs[index.row()] if api.get("protocols"): self._add_new_api(api) return def _show_related_mashups(self): self.switch_btn_apis.hide() self.switch_btn_mashups.hide() self.recommendLabel.hide() apis = [] objs = [] for mashup in self.related_mashups: apis.extend(mashup["related_mashups"]) for api in apis: objs.append(api) mashups = self.data_source.mashups_by_api(api) objs.extend(mashups) row = 0 model = QStandardItemModel(len(objs), 4) model.setColumnCount(4) for obj in objs: if obj.get('protocols'): model.setData(model.index(row, 0), get_api_name(obj)) model.setData(model.index(row, 1), obj['protocols']) model.setData(model.index(row, 2), obj['provider']) else: model.setData(model.index(row, 3), get_mashup_name(obj)) row += 1 model.setHeaderData(0, Qt.Horizontal, "API") model.setHeaderData(1, Qt.Horizontal, "Protocols") model.setHeaderData(2, Qt.Horizontal, "Provider") model.setHeaderData(3, Qt.Horizontal, "Mashup") self.table.setModel(model) self.table.resizeColumnsToContents() self.switch_btn_apis.show() def _show_related_apis(self): self.switch_btn_apis.hide() self.switch_btn_mashups.hide() self.recommendLabel.hide() row = 0 objs = [] for mashup in self.related_mashups: objs.append(mashup) for api in mashup["related_mashups"]: objs.append(api) #Combining similarity and related. similar_apis = self.data_source.search_api_similarity(self.highlighted_api) #return str(mashup['id'])[(len("http://www.programmableweb.com/mashup/")):] objs.append({'id': "http://www.programmableweb.com/mashup/Using-Similarity-Metric"}) objs.extend(similar_apis) #Combining similarity and related. #http://localhost:9000/getReputation/John%20Lions model = QStandardItemModel(len(objs), 6) for obj in objs: if obj.get('protocols'): model.setData(model.index(row, 1), get_api_name(obj)) model.setData(model.index(row, 2), obj['protocols']) model.setData(model.index(row, 3), obj['provider']) model.setData(model.index(row, 4), obj['version']) #trust = requests.get('http://localhost:9000/getReputation/Luis Ramos').content model.setData(model.index(row, 5), str(random.random())) #model.setData(model.index(row, 5), QVariant(trust)) else: model.setData(model.index(row, 0), get_mashup_name(obj)) row += 1 model.setHeaderData(0, Qt.Horizontal, "Mashup") model.setHeaderData(1, Qt.Horizontal, "API") model.setHeaderData(2, Qt.Horizontal, "Protocols") model.setHeaderData(3, Qt.Horizontal, "Provider") model.setHeaderData(4, Qt.Horizontal, "Version") model.setHeaderData(5, Qt.Horizontal, "Trust") self.table.setModel(model) self.table.resizeColumnsToContents() self.switch_btn_mashups.show() def _add_new_api(self, api): self.highlighted_api = api mashups = self.data_source.mashups_by_api(api) for mashup in mashups: mashup['related_mashups'] = (self.data_source.apis_by_mashup(mashup)) if len(mashups) > 0: self.related_mashups = mashups self._show_related_apis() manager = core.packagemanager.get_package_manager() reg = core.modules.module_registry.get_module_registry() package = manager.get_package("edu.cmu.sv.components", "1.0.0") core.modules.module_registry.set_current_package(package) if (api["protocols"] == "SOAP" and api["wsdl"] != ""): s = Service(api["wsdl"]) # add_new_service(s, api["wsdl"]) else: new_module = vistrails_module.new_module(Module, get_api_name(api)) reg.add_module(new_module) reg.add_input_port(new_module, "value1", (core.modules.basic_modules.String, 'the first argument')) reg.add_input_port(new_module, "value2", (core.modules.basic_modules.String, 'the second argument')) reg.add_output_port(new_module, "value", (core.modules.basic_modules.String, 'the result')) # def loadClimateDataSet(self): # filename = '/home/hywel/Documents/VisTrailsRecommendation/vistrails_current/vistrails/packages/componentSearch/Climate_Datasets.csv' # with open(filename, mode='r') as infile: # reader = csv.reader(infile) # next(reader, None) # with open('coors_new.csv', mode='w') as outfile: # writer = csv.writer(outfile) # climateData = {} # for row in reader: # id = int(row[0]) # climateData[id] = {} # climateData[id]["dataset"] = row[1] # climateData[id]["agency"] = row[2] # climateData[id]["instrument"] = row[3] # climateData[id]["pvar"] = row[4] # climateData[id]["var"] = row[5] # climateData[id]["units"] = row[6] # climateData[id]["grid"] = row[7] # climateData[id]["webvar"] = row[8] # climateData[id]["input"] = row[9] # climateData[id]["start"] = row[10] # climateData[id]["end"] = row[11] # return climateData def parseServerData(self, data): climateData = {} for dataset in data: id = int(dataset["datasetID"]) climateData[id] = {} climateData[id]["name"] = dataset["dataset"] climateData[id]["agency"] = dataset["agency"] climateData[id]["instrument"] = dataset["instrument"] climateData[id]["pvar"] = dataset["pvar"] climateData[id]["var"] = dataset["var"] climateData[id]["units"] = dataset["units"] climateData[id]["grid"] = dataset["grid"] climateData[id]["webvar"] = dataset["webvar"] climateData[id]["input"] = dataset["input"] climateData[id]["start"] = dataset["start"] climateData[id]["end"] = dataset["end"] return climateData
from PyQt4.QtGui import QApplication, QWidget import sys if __name__ == '__main__': print('HOLA') app = QApplication(sys.argv) w = QWidget() w.resize(250, 150) w.move(300, 300) w.setWindowTitle('Simple') w.show() print('HOLA') sys.exit(app.exec_())
class QPlayer(QWidget, Ui_QPlayer): def __init__(self, handModel, gameDialog, gameType, controllable, playerName, parent=None): QWidget.__init__(self, parent) self.setupUi(self) self.controllable = controllable self.name = playerName if gameType is utilities.kGameTypeYuGiOh: self.btnDeck.pixmap = QPixmap("images/yugiohBack.jpg") self.piPlayerInfo.setLife(8000) self.piPlayerInfo.hidePoison() else: self.btnDeck.pixmap = QPixmap("images/back.jpg") self.btnDeck.displaysTopCard = False self.btnDeck.enlargeFunction = gameDialog.enlargeCard self.btnGraveyard.pixmap = QPixmap("images/empty.jpg") self.btnGraveyard.enlargeFunction = gameDialog.enlargeCard self.btnGraveyard.controllable = controllable self.gameType = gameType if gameType is utilities.kGameTypeTwoHeadedGiant: self.piPlayerInfo.setLife(30) # Setup models self.creaturesModel = QCardModel(self, self.controllable, 140) self.creaturesModel.enlargeFunction = gameDialog.enlargeCard self.landsModel = QCardModel(self, self.controllable, 140) self.landsModel.enlargeFunction = gameDialog.enlargeCard self.graveyardModel = QCardModel(self, self.controllable) self.graveyardModel.enlargeFunction = gameDialog.enlargeCard self.handModel = handModel self.handModel.enlargeFunction = gameDialog.enlargeCard self.exileModel = QCardModel(self, self.controllable) self.exileModel.enlargeFunction = gameDialog.enlargeCard if self.gameType is not utilities.kGameTypeYuGiOh: self.deck = QDeck(self, controllable, game="Magic") else: self.deck = QDeck(self, controllable, game="Yu-Gi-Oh") self.deck.enlargeFunction = gameDialog.enlargeCard # Handle commander format if gameType is utilities.kGameTypeCommander: self.lblCommander.show() else: self.lblCommander.hide() # Connect Views and Models self.lvCreatures.setModel(self.creaturesModel) self.lvLands.setModel(self.landsModel) self.btnGraveyard.setModel(self.graveyardModel) self.gameDialog = gameDialog # Connect signals and slots if self.controllable: self.connect(self.btnDeck, SIGNAL("clicked()"), self.drawCard) self.connect(self.lvCreatures, SIGNAL('doubleClicked(QModelIndex)'), self.creaturesModel.toggleCardAtIndexTapped) self.connect(self.lvCreatures, SIGNAL('customContextMenuRequested(QPoint)'), self.creaturesModel.contextMenuFunction(self.lvCreatures, self, gameDialog, self)) self.connect(self.lvLands, SIGNAL('doubleClicked(QModelIndex)'), self.landsModel.toggleCardAtIndexTapped) self.connect(self.lvLands, SIGNAL('customContextMenuRequested(QPoint)'), self.landsModel.contextMenuFunction(self.lvLands, self, gameDialog, self)) self.connect(self.btnDeck, SIGNAL('customContextMenuRequested(QPoint)'), self.displayDeckMenu) self.connect(self.lvCreatures, SIGNAL("clicked(QModelIndex)"), self.enlargeCreature) self.connect(self.lvLands, SIGNAL("clicked(QModelIndex)"), self.enlargeLand) self.connect(self.btnGraveyard, SIGNAL('customContextMenuRequested(QPoint)'), self.displayGraveyardMenu) self.btnDeck.setContextMenuCallback(self.displayDeckDragAndDropMenu) self.piPlayerInfo.hide() def setGameType(self, gameType): self.gameType = gameType def hideDeck(self): for i in range(0, self.vlDeck.count()): self.vlDeck.itemAt(i).widget().hide() self.piPlayerInfo.show() def flip(self): return flippedWidgets = [] for row in range(0,self.layout().rowCount()): rowWidgets = [] for column in range(0,self.layout().columnCount()): item = self.layout().itemAtPosition(row,column) rowWidgets.append(item) self.layout().removeItem(item) flippedWidgets.insert(0, rowWidgets) for y,row in enumerate(flippedWidgets): for x,widget in enumerate(row): self.layout().addItem(widget, y, x) def drawCard(self): abbreviation, index = self.deck.drawCard() self.handModel.addItem(QCard(abbreviation, index)) def setDeckFromFile(self,filename): print "Loading deck %s..." % filename import os; print os.getcwd() self.deck.loadFromFile(filename) self.setupDeck() def setRandomDeckFromColors(self, colors): self.deck.randomFromColors(colors) self.setupDeck() def setupDeck(self): self.updateDeckSize() self.btnDeck.setModel(self.deck) self.connect(self.deck, SIGNAL('rowsInserted(QModelIndex,int,int)'), self.updateDeckSize) self.connect(self.deck, SIGNAL('rowsRemoved(QModelIndex,int,int)'), self.updateDeckSize) if self.gameType is utilities.kGameTypeCommander: commanderCard = self.deck.removeCommanderFromDeck() if commanderCard is not None: self.lblCommander.setPixmap(commanderCard.pixmap()) def updateDeckSize(self, ignored1=None,ignored2=None,ignored3=None): self.lblDeckSize.setText("%d Cards in Deck" % (len(self.deck.list))) def enlargeLand(self, index): self.gameDialog.enlargeCard(self.landsModel.list[index.row()]) def enlargeCreature(self, index): self.gameDialog.enlargeCard(self.creaturesModel.list[index.row()]) def untapAll(self): self.creaturesModel.untapAll() self.landsModel.untapAll() def displayDeckMenu(self, pt): menu = QMenu() menu.addAction("Shuffle", self.deck.shuffle) menu.addAction("View Library", self.btnDeck.viewContents) menu.addAction("Reveal top card") # TODO: Implement def millFunction(number): def millCards(): for i in range(number): card = self.deck.list[-1] self.deck.removeItem(card) self.graveyardModel.addItem(card,0) return millCards millSubmenu = menu.addMenu("Mill") millSubmenu.addAction("Mill 1", millFunction(1)) millSubmenu.addAction("Mill 2", millFunction(2)) millSubmenu.addAction("Mill 3", millFunction(3)) millSubmenu.addAction("Mill 5", millFunction(5)) menu.exec_(self.btnDeck.mapToGlobal(pt)) def displayGraveyardMenu(self, pt): menu = QMenu() menu.addAction("View Graveyard", self.btnGraveyard.viewContents) if self.controllable: menu.addAction("Exile All") #TODO: Implement menu.exec_(self.btnGraveyard.mapToGlobal(pt)) def displayDeckDragAndDropMenu(self): print "Displaying menu" menu = QMenu() menu.addAction("Send to top") menu.addAction("Send to botton") result = menu.exec_(QCursor.pos()) if result.text() == "Send to top": return len(self.deck.list) else: return 0 # Send to bottom def askToAddToken(self): picker = QItemPicker(self, self.addToken, QTokenListModel(self), "Token") picker.show() def addToken(self, filename): card = QCard('tokens',filename) self.creaturesModel.addItem(card) def displayExile(self): from PyQt4.QtGui import QListView, QAbstractItemView, QPushButton, QVBoxLayout, QLabel from PyQt4.QtCore import QSize from util import utilities windowSize = self.window().frameSize() self.viewer = QWidget(self.window()) self.viewer.move(10,10) self.viewer.resize(QSize(windowSize.width()-(25+utilities.bigCardSize[0]),275)) lvViewer = QListView(self.viewer) lvViewer.setModel(self.model) lvViewer.setDragEnabled(True) lvViewer.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel) lvViewer.setFlow(QListView.LeftToRight) lvViewer.setFocus() self.connect(lvViewer, SIGNAL('clicked(QModelIndex)'), self.enlarge) button = QPushButton("Close", self.viewer) self.connect(button,SIGNAL('clicked()'),self.hideViewer) layout = QVBoxLayout(self) layout.addWidget(QLabel("I'm sorry this is so ugly.",self.viewer)) layout.addWidget(lvViewer) layout.addWidget(button) self.viewer.setLayout(layout) self.viewer.show() ################################## #### Networking Methods ########## #### Called by QPTG ########## ################################## def addCardTo(self, pickledCard, zone, position): # card = pickle.loads(pickledCard) card = QCard.unserializeCard(pickledCard) if int(zone) is Networking.QGameClient.HAND: self.piPlayerInfo.setHandSize(self.piPlayerInfo.handSize()+1) if int(zone) is Networking.QGameClient.DECK: self.piPlayerInfo.setDeckSize(self.piPlayerInfo.deckSize()+1) if int(zone) is Networking.QGameClient.EXILE: self.exileModel.addItem(card, int(position)) if int(zone) is Networking.QGameClient.GRAVEYARD: self.graveyardModel.addItem(card, int(position)) if int(zone) is Networking.QGameClient.CREATURES: self.creaturesModel.addItem(card, int(position)) if int(zone) is Networking.QGameClient.LANDS: self.landsModel.addItem(card, int(position)) def removeCardFrom(self, zone, position): if int(zone) is Networking.QGameClient.HAND: self.piPlayerInfo.setHandSize(self.piPlayerInfo.handSize()-1) if int(zone) is Networking.QGameClient.DECK: self.piPlayerInfo.setDeckSize(self.piPlayerInfo.deckSize()-1) if int(zone) is Networking.QGameClient.EXILE: self.exileModel.removeItem(self.exileModel.list[int(position)]) if int(zone) is Networking.QGameClient.GRAVEYARD: self.graveyardModel.removeItem(self.graveyardModel.list[int(position)]) if int(zone) is Networking.QGameClient.CREATURES: self.creaturesModel.removeItem(self.creaturesModel.list[int(position)]) if int(zone) is Networking.QGameClient.LANDS: self.landsModel.removeItem(self.landsModel.list[int(position)]) def setCardTo(self, pickledCard, zone, position): card = QCard.unserializeCard(pickledCard) if int(zone) is Networking.QGameClient.EXILE: self.exileModel.setItem(card, int(position)) if int(zone) is Networking.QGameClient.GRAVEYARD: self.graveyardModel.setItem(card, int(position)) if int(zone) is Networking.QGameClient.CREATURES: self.creaturesModel.setItem(card, int(position)) if int(zone) is Networking.QGameClient.LANDS: self.landsModel.setItem(card, int(position))