def select_box(self, event, r): UndoManager.begin_action(end_timeout=500) modifiers = event.modifiers() if ((modifiers != Qt.ShiftModifier) and (modifiers != Qt.ControlModifier)): Selection.deselect_all() self._select_children_in_box(self, r, modifiers, set())
def on_click(self, event): item = self.scene().itemAt(event.scenePos()) if (item is not self): return if (len(Selection.models) > 0): Selection.deselect_all() else: add_menu = menu.WorkspaceMenu(document=self.document, event=event, parent=event.widget()) add_menu.popup(event.screenPos())
def on_drag_start_y(self, event): UndoManager.begin_action() # select the model if it isn't selected if (not self.model.selected): Selection.deselect_all() self.model.selected = True # record the original pitches of all selected models self._drag_start_pitches = dict() for model in Selection.models: try: self._drag_start_pitches[model] = model.pitch except AttributeError: continue
def create_selection(student_id, course_id): student = query_user_by_numid('student', student_id) course = query_course_by_id(course_id) if not course: raise APIError(u'课程不存在', status_code=404) sel = Selection() sel.student = int(student_id) sel.course = int(course_id) sel.term = '' db.session.add(sel) db.session.commit() return sel.dict
def on_drag_start_x(self, event): UndoManager.begin_action() # select the model if it isn't selected can_select = hasattr(self.model, 'selected') if ((not can_select) or (not self.model.selected)): Selection.deselect_all() if (can_select): self.model.selected = True # record the original times of all selected models self._drag_start_times = dict() models = set(Selection.models) models.add(self.model) for model in models: try: self._drag_start_times[model] = model.time except AttributeError: continue
def on_click(self, event): UndoManager.begin_action(end_timeout=500) if ((self.allow_multiselect) and (event.modifiers() == Qt.ShiftModifier)): self.model.selected = True elif ((self.allow_multiselect) and (event.modifiers() == Qt.ControlModifier)): self.model.selected = not self.model.selected else: try: if (self.model.selected): event.ignore() return except AttributeError: pass Selection.deselect_all() self.model.selected = True
def send_message(): message = request.form['content'] project_id = os.getenv("DIALOGFLOW_PROJECT_ID") fulfillment_text, action = detect_intent_texts(project_id, "unique", message, 'en') type, contents, msg = '', None, '' # return recommend movie list if action == 'recommendation': state = recommend_movie.get_user_rs_state() # personalized recommendation if state == '1': recommend_movie.store_user_profile() search_results = recommend_movie.recommand_movies() contents = {'playlists': search_results} msg = 'You can tell me the number or touch the option to choose the recommended movie' type = 'movielist' # recommend according to the movie's hotness else: search_results = recommend_movie.recommond_hotest_movie() contents = {'playlists': search_results} msg = 'You can tell me the number or touch the option to choose the recommended movie' type = 'movielist' # reply fulfillment_text set in dialogflow elif action == 'input.unknown': msg = fulfillment_text type = 'text' contents = {} elif action[:5] == "movie": # ERROR: multiple movies if fulfillment_text == "0": msg = 'only one movie permitted' type = 'text' # give information for the movie else: if action == "movie.trailer": movie_name, type_of_info = fulfillment_text.split("#") video_info = video_service.youtube_search(movie_name)[0] type = 'video' msg = more_human.wrong_movie_response() contents = video_info else: movie_name, type_of_info = fulfillment_text.split("#") moive_data = movie_info.get_movie_info(movie_name) contents = { 'type': movie_info_type[type_of_info], 'movie': moive_data } msg = more_human.wrong_movie_response() type = 'movie_info' year = movie_info.get_movie_year(movie_name) recommend_movie.init_feedback(movie_name, int(year)) # based on the movie name user given in last step, generate search result list elif action == "notasexpected": movie_name, type_of_info = fulfillment_text.split('#') search_results = movie_info.find_results(movie_name, type_of_info) msg = 'You can tell me the number or touch the option to choose the movie you expected' contents = {'playlists': search_results} type = 'movielist' # select movie from search result list elif action == "select.movie": # ERROR: input multiple number if len(fulfillment_text) > 10: msg = fulfillment_text type = "text" # base on the number user choose, return the corresponding movie info else: number, type_of_info = fulfillment_text.split('#') number = int(number) contents = Selection(response_type["movie_info"], number, type_of_info).to_dict() msg = more_human.movie_selection_response() type = 'list_selection' # select movie from result recommendation list elif action == "select.rs": # ERROR: input multiple number if len(fulfillment_text) > 10: msg = fulfillment_text type = "text" # base on the number user choose, return the corresponding movie info else: number, type_of_info = fulfillment_text, 'overview' number = int(number) contents = Selection(response_type["movie_info"], number, type_of_info).to_dict() msg = more_human.movie_selection_response() type = 'list_selection' # small talk elif "smalltalk" in action: type = "text" msg = fulfillment_text + " you can ask me information about movies(details,actors,rating etc) and play music for you by asking the artists or their albums. i can also obtain the health data from your Apple Watch if you have one. Oh!dont't forget to connect your LIFX buble so you can control it from here" contents = fulfillment_text # defalut welcome elif action == "input.welcome": type = "text" msg = fulfillment_text + " you can ask me information about movies(details,actors,rating etc) and play music for you by asking the artists or their albums. i can also obtain the health data from your Apple Watch if you have one. Oh!dont't forget to connect your LIFX buble so you can control it from here" contents = fulfillment_text # health elif action == "health": health_type, start_date, end_date = fulfillment_text.split('#') if health_type == 'None': msg = 'could you say that again?' type = 'text' contents = {} else: msg = health_record.generate_res(health_type, start_date, end_date) type = 'health' health_type = health_type.split(',') contents = { 'start': start_date, 'end': end_date, 'type': health_info_type[health_type[0]] } # player function elif action[:6] == "player": contents = Music_Instruction( music_instruction[action_to_type[fulfillment_text]]).to_dict() type = "music_control" msg = more_human.music_instrction_response( music_instruction[action_to_type[fulfillment_text]]) # user's own playlists list elif action == 'music.playlist': contents = music_player.show_playlist() msg = more_human.music_playlist_response() type = "playlist" # top Ten elif action == "music.topten": # ERROR: multiple singers if fulfillment_text == '0': msg = 'one singer only.' type = "text" # return a certain singer's top-ten songs list else: contents = music_player.show_top_tracks(fulfillment_text) msg = more_human.music_topten_response(fulfillment_text) type = "track" # albums elif action == "music.album": # ERROR: multiple singers if fulfillment_text == '0': msg = 'one singer only.' type = "text" # return one singer's albums list else: contents = music_player.show_artist_albums(fulfillment_text) msg = more_human.music_album_response(fulfillment_text) type = "album" # selection in music part elif action == "select.music": # ERROR: multiple numbers if len(fulfillment_text) > 5: msg = fulfillment_text type = "text" # return the number user selected else: contents = Selection(response_type["playlist"], fulfillment_text).to_dict() type = 'list_selection' else: msg = fulfillment_text type = 'text' response_text = Response(type=response_type[type], message=msg, status=1, contents=contents).to_dict() # state == 1 ? return jsonify(response_text)
def on_click(self, event): if (event.modifiers() == 0): Selection.deselect_all()
from flask import Flask from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////home/raviteja/betbright/betBright.db' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True db = SQLAlchemy(app) # See important note below from model import Market from model import Selection from model import Event from model import Message from model import Sport #Simple data insertions for available tables s1 = Selection(name="Poland",odds=3.01) s2 = Selection(name="Irland",odds=7.01); m1 = Market(name="Winner",selections=[s1,s2]) ev1 = Event("Poland vs Irland","http://example.com/api/match/2",2,1) db.session.add(m1) db.session.add(s1) db.session.add(s2) db.session.add(ev1) db.session.commit()