def adjust_row(view, glued, row, widths): row_tabs = tabs_for_row(view, row) if len(row_tabs) == 0: return glued bias = 0 location = -1 for w, it in zip(widths,row_tabs): location += 1 + w it += bias difference = location - it if difference == 0: continue end_tab_point = view.text_point(row, it) partial_line = view.substr(view.line(end_tab_point))[0:it] stripped_partial_line = partial_line.rstrip() ispaces = len(partial_line) - len(stripped_partial_line) if difference > 0: view.run_command("maybe_mark_undo_groups_for_gluing") glued = True with Edit(view, "ElasticTabstops") as edit: #put the spaces after the tab and then delete the tab, so any insertion #points behave as expected edit.insert(end_tab_point+1, (' ' * difference) + "\t") edit.erase(sublime.Region(end_tab_point, end_tab_point + 1)) bias += difference if difference < 0 and ispaces >= -difference: view.run_command("maybe_mark_undo_groups_for_gluing") glued = True with Edit(view, "ElasticTabstops") as edit: edit.erase(sublime.Region(end_tab_point, end_tab_point + difference)) bias += difference return glued
def __init__(self, window, outputs, encoders): Edit.__init__(self, window, outputs) label = self.interface.get_object("name_label") label.set_label("Output name:") self.dialog.set_title("Edit Output") self.encoders = encoders self.encoder_box = None
def set_factory(self, factory): Edit.set_factory(self, factory) if self.encoder_box: self.container_box.remove(self.encoder_box) self.encoder_box = factory.get_ui().get_encoder_widget() self.container_box.add(self.encoder_box) factory.get_ui().set_encoder_model(self.encoders.liststore)
def get_edit(edit_type='default', widget_name='GetValue', initial_value='aBc', label_text='', Left=0, Height=23, Top=0, Width=80, TopMargin=10, RightMargin=10, BottomMargin=10, LeftMargin=10, has_OnClick=False, has_OnChange=True, AutoSize=False): if label_text: if edit_type == 'default': return LabeledEdit(**key_word_args(EDIT_PARAML, locals())) else: VLay = VStackPanel() VLay.add_widget( Label(widget_name=widget_name + 'Label', Caption=label_text, BottomMargin=0)) widget = Edit(**key_word_args(EDIT_PARAML, locals())) widget.TopMargin = 0 widget.label_text = '' VLay.add_widget(widget) return VLay else: return Edit(**key_word_args(EDIT_PARAML, locals()))
def EditMark(): if len(Edit().student.marks) == 0: print('Оценок нет') else: Edit().student.printSubjects() n = input('Введите название предмета: ') if n not in Edit().student.marks: print("Такого предмента нет") return Edit().student.marks[n] = int(input('Введите оценку: '))
def __init__(self, window, sources, audioconvs): Edit.__init__(self, window, sources) for (name1, source) in sources.liststore: source.set_parent(None) for (name2, audio) in audioconvs.liststore: if name1 == name2: source.set_parent(audio) label = self.interface.get_object("name_label") label.set_label("Source name:") self.dialog.set_title("Edit Source") self.audio_list = audioconvs
def right_click_options(self): self.rightclickmenu.add_command(label="Copy", command=lambda: Edit.copy(self)) self.rightclickmenu.add_command(label="Paste", command=lambda: Edit.paste(self)) self.rightclickmenu.add_command(label="Cut", command=lambda: Edit.cut(self)) self.rightclickmenu.add_command(label="Select all", command=lambda: Edit.select_all(self)) self.rightclickmenu.add_command(label="New File", command=lambda: File.new_file(self)) self.rightclickmenu.add_command(label="Close File", command=lambda: File.close_file(self))
def initModule(self, data): self.layout = QHBoxLayout() self.label = Label(data) self.labelEdit = Edit(self) self.labelEdit.hide() self.doneBtn = Button() self.layout.addWidget(self.label, 1, Qt.AlignLeft) self.layout.addSpacing(10) self.layout.addWidget(self.labelEdit, 1, Qt.AlignLeft) self.layout.addWidget(self.doneBtn, 1, Qt.AlignLeft) self.layout.setContentsMargins(1, 10, 1, 10) self.layout.setSpacing(1) self.setLayout(self.layout)
def run(self, edit, extend): view = self.view oriSels = [sel for sel in view.sel()] v = view.window().show_input_panel( "Select Until Next -- chars or [chars] or {count} or /regex/. Use minus (-) to reverse search:", SelectUntilCommand.prevSelector, lambda selector: on_done(view, extend), lambda selector: on_change(view, oriSels, selector, extend), lambda: on_cancel(view, oriSels)) # view.window().show_input_panel returns None when input_panel is already shown in subl v2 if v is not None: v.sel().clear() v.sel().add(Region(0, v.size())) SelectUntilCommand.input_panel = v input_panel = SelectUntilCommand.input_panel if input_panel and not SelectUntilCommand.first_opened: fullRegion = Region(0, input_panel.size()) isReverse, negSelector = negate_selector( input_panel.substr(fullRegion)) highlight = Region(1 + (1 if isReverse else 0), len(negSelector) - 1) with Edit(input_panel) as edit: edit.replace(fullRegion, negSelector) input_panel.sel().clear() input_panel.sel().add(highlight) SelectUntilCommand.first_opened = False
def insertedit(self): data = self.fetchdet() self.withdraw() try: Edit(self, self.ideatime, *data) except: pass
def test_edit(): assert Edit("a", "b").distance() == 1 assert Edit("a", "aa").distance() == 1 assert Edit("scissor", "sisters").distance() == 4 assert Edit("bonjour", "au revoir").distance() == 7 assert len(Edit("aaa", "aaabc").compute_path()) == 3 assert "bordeaux" in Edit("bourgogne", "bordeaux").compute_path() assert len(Edit("bonjour", "au revoir").compute_path()) == 8 assert 'aaa aac abc bc' == " ".join(Edit("aaa", "bc").compute_path())
def __init__(self, window, encodings, converters): Edit.__init__(self, window, encodings) for (name1, encoder) in encodings.liststore: for (name2, converter) in converters.liststore: if name1 == name2: encoder.set_parent(converter) label = self.interface.get_object("name_label") label.set_label("Encoding name:") self.dialog.set_title("Edit Encoding") self.converter_factory = self.registry.get_factories( REGISTRY_VIDEO_CONVERTER)[0] self.setting_box = self.converter_factory.get_ui().get_widget() self.container_box.add(self.setting_box) self.converter_list = converters
def RemoveMark(): if len(Edit().student.marks) == 0: print('Оценок нет') else: Edit().student.printSubjects() n = input('Введите название предмета: ') if n not in Edit().student.marks: print("Такого предмента нет") return while True: p = input(f'Удалить оценку {n}?\n1.Да\n2.нет\n') if p == '2' or p == '1' or p == 'да' or p == 'Да' or p == 'Нет' or p == 'нет': break else: print('error') if p == '1' or p == 'да' or p == 'Да': del Edit().student.marks[n] print('Вы удалили оценку') pass
def __init__(self, window, encodings, converters): Edit.__init__(self, window, encodings) for (name1, encoder) in encodings.liststore: for (name2, converter) in converters.liststore: if name1 == name2: encoder.set_parent(converter) label = self.interface.get_object("name_label") label.set_label("Encoding name:") self.dialog.set_title("Edit Encoding") self.converter_factory = self.registry.get_factories( REGISTRY_VIDEO_CONVERTER )[0] self.setting_box = self.converter_factory.get_ui().get_widget() self.container_box.add(self.setting_box) self.converter_list = converters
def SelectS(): if StudentRegistry().getStudentsCount() != 0: studentRegistry.visit_students(BriefPrintVisitor()) while True: n = int(input('Введите номер ученика ')) - 1 if StudentRegistry().getStudentsCount() > n >= 0: break print('error') Edit().student = StudentRegistry().getStudent(n) else: return True
def __init__(self): # config self.config_provider = ConfigProvider() # disk self.disk = Disk() # display self.display = None if (self.config_provider.edit_enabled or self.config_provider.effects_enabled or self.config_provider.audio_enabled or self.config_provider.screen_enabled): self.display = Display() # replay self.replay = None if (self.config_provider.edit_enabled or self.config_provider.audio_enabled or self.config_provider.screen_enabled): self.replay = Replay() # graphics self.graphics = None if (self.config_provider.effects_enabled or self.config_provider.audio_enabled or self.config_provider.screen_enabled): self.graphics = Graphics() # record self.record = None if self.config_provider.record_enabled: self.record = Record(self.config_provider, self.disk) # edit self.edit = None if self.config_provider.edit_enabled: self.edit = Edit(self.config_provider, self.disk, self.display, self.replay) # effects self.effects = None if self.config_provider.effects_enabled: self.effects = Effects(self.config_provider, self.disk, self.display, self.graphics) # audio self.audio = None if self.config_provider.audio_enabled: self.audio = Audio(self.config_provider, self.disk, self.display, self.replay, self.graphics) # screen self.screen = None if self.config_provider.screen_enabled: self.screen = Screen(self.config_provider, self.disk, self.display, self.replay, self.graphics) # frame number self.frame_number = 0
def main(): cur_user = users.add_user() while True: create = Create(shared, cur_user) edit = Edit(shared, cur_user) read = Read(shared, cur_user) print(f"\nCurrent User: {cur_user}") choice = main_menu_funct() if choice == 0: break if choice == 1: create.create() if choice == 2: read.read_by_date() if choice == 3: read.read_all() if choice == 4: edit.modify() if choice == 5: edit.remove() if choice == 6: cur_user = users.add_user() if choice == 7: cur_user = users.load_user() if choice == 8: save()
def inser_back(self, num): """2nd menu directing the Insert/Back options.""" if num == 0: buffr = "\n".join(self.inser_content[self.selected_example]) view = self.window.active_view() with Edit(view) as edit: for r in view.sel(): if r.empty(): edit.insert(r.a, buffr[16:]) else: edit.replace(r, buffr[16:]) if num == 1: self.done(self.num)
class PyMovieStudio: # initialise def __init__(self): # config self.config_provider = ConfigProvider() # disk self.disk = Disk() # display self.display = None if (self.config_provider.edit_enabled or self.config_provider.effects_enabled or self.config_provider.audio_enabled or self.config_provider.screen_enabled): self.display = Display() # replay self.replay = None if (self.config_provider.edit_enabled or self.config_provider.audio_enabled or self.config_provider.screen_enabled): self.replay = Replay() # graphics self.graphics = None if (self.config_provider.effects_enabled or self.config_provider.audio_enabled or self.config_provider.screen_enabled): self.graphics = Graphics() # record self.record = None if self.config_provider.record_enabled: self.record = Record(self.config_provider, self.disk) # edit self.edit = None if self.config_provider.edit_enabled: self.edit = Edit(self.config_provider, self.disk, self.display, self.replay) # effects self.effects = None if self.config_provider.effects_enabled: self.effects = Effects(self.config_provider, self.disk, self.display, self.graphics) # audio self.audio = None if self.config_provider.audio_enabled: self.audio = Audio(self.config_provider, self.disk, self.display, self.replay, self.graphics) # screen self.screen = None if self.config_provider.screen_enabled: self.screen = Screen(self.config_provider, self.disk, self.display, self.replay, self.graphics) # frame number self.frame_number = 0 # initialise OpenGL def _init_opengl(self): glClearColor(0.0, 0.0, 0.0, 0.0) glClearDepth(1.0) glDepthFunc(GL_LESS) glEnable(GL_DEPTH_TEST) glShadeModel(GL_SMOOTH) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(33.7, 1.3, 0.1, 100.0) glMatrixMode(GL_MODELVIEW) # process frame def _process_frame(self): glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glLoadIdentity() # record if self.record: if self.record.frame(self.frame_number) == False: return # edit if self.edit: if self.edit.frame(self.frame_number) == False: return # effects if self.effects: if self.effects.frame(self.frame_number) == False: return # audio if self.audio: if self.audio.frame(self.frame_number) == False: return # screen if self.screen: if self.screen.frame(self.frame_number) == False: return # increment frame number self.frame_number += 1 glutSwapBuffers() def main(self): # setup and run OpenGL glutInit() glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH) glutInitWindowSize(640, 480) glutInitWindowPosition(100, 100) glutCreateWindow('PyMovieStudio') glutDisplayFunc(self._process_frame) glutIdleFunc(self._process_frame) self._init_opengl() glutMainLoop()
del self.Left del self.Top del self.Width del self.Height if __name__ == '__main__': from button import Button from edit import Edit from layout import VStackPanel, HStackPanel Lay = VStackPanel(Left=10, Height=0, Top=10, Width=0, TopMargin=10, RightMargin=10, BottomMargin=10, LeftMargin=10) Lay.add_widget( Edit( widget_name='Get_Text', initial_value='Hi') ) Lay.add_widget( Edit( widget_name='Get_Int', initial_value=3) ) Lay.add_widget( Edit( widget_name='Get_Float', initial_value=5.55) ) Lay.add_widget( Edit( widget_name='Get_Bool', initial_value=True) ) P = PageControl(widget_name='MyPageControl', Left=0, Height=100, Top=0, Width=200) P.add_tabsheet( TabSheet( layout=Lay, widget_name='MyTab1', Left=41, Height=25, Top=42, Width=75) ) #print 'child_widgetL =',P.child_widgetL Lay = HStackPanel(Left=10, Height=0, Top=10, Width=0, TopMargin=10, RightMargin=10, BottomMargin=10, LeftMargin=10) Lay.add_widget( Edit( widget_name='Get_Text', initial_value='Hi') ) Lay.add_widget( Edit( widget_name='Get_Int', initial_value=3) ) P.add_tabsheet( TabSheet( layout=Lay, widget_name='MyTab2', Left=41, Height=25, Top=42, Width=75) )
def AddMark(): с = input('Введите название предмета: ') Edit().student.marks[с] = int(input('Введите оценку: '))
def insert(self, text, start): with Edit(self.view) as edit: edit.insert(start, str(text))
def ShowS(): if StudentRegistry().getStudentsCount() != 0: Edit().student.printLong() StudentRegistry().save() test()
from edit import Edit from manipularArquivo import lerArquivo arquivo = lerArquivo("models.py") var = Edit(arquivo) var.generate_dict_repr()
class Memo(QWidget): def __init__(self, parent=None, data=None): super(Memo, self).__init__(parent) self.initData(parent) self.initModule(data) self.setModule(data) # data self.loadInfo(data) #button self.doneBtn.clicked.connect(self.done) self.labelEdit.sureBtn.clicked.connect(self.save) def initData(self, parent): self.pw = parent self.data = parent.data def initModule(self, data): self.layout = QHBoxLayout() self.label = Label(data) self.labelEdit = Edit(self) self.labelEdit.hide() self.doneBtn = Button() self.layout.addWidget(self.label, 1, Qt.AlignLeft) self.layout.addSpacing(10) self.layout.addWidget(self.labelEdit, 1, Qt.AlignLeft) self.layout.addWidget(self.doneBtn, 1, Qt.AlignLeft) self.layout.setContentsMargins(1, 10, 1, 10) self.layout.setSpacing(1) self.setLayout(self.layout) def setModule(self, data): self.setMinimumWidth(400) #set size self.label.setMargin(2) self.label.setWordWrap(True) #auto newline self.label.setMinimumWidth(340) self.label.setMaximumWidth(340) self.label.setMinimumHeight(50) self.labelEdit.setMinimumHeight(50) self.labelEdit.setMaximumHeight(50) self.doneBtn.setMinimumSize(45, 45) self.doneBtn.setMaximumSize(45, 45) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) # set style self.doneBtn.setStyleSheet(css.memo_btn_no) self.no = True self.label.setStyleSheet( css.memo_label.replace('fc', data['font_color']).replace( 'bgc', data['background_color'])) def loadInfo(self, data): self.id = data['id'] if 'content' in data: content = data['content'] else: content = 'It is empty!' self.label.setText(content) self.labelEdit.setText(content) if data['font_bold'] == 'Bold': font = QFont(data['font'], data['font_size'], QFont.Bold) else: font = QFont(data['font'], data['font_size'], 50) self.label.setFont(font) def done(self): if self.no: self.doneBtn.setStyleSheet(css.memo_btn_yes) self.no = False else: self.doneBtn.setStyleSheet(css.memo_btn_no) self.no = True def save(self): txt = self.labelEdit.document() self.label.setText(txt.toPlainText()) self.label.show() self.doneBtn.show() self.labelEdit.hide() self.saveData(txt.toPlainText()) def saveData(self, data): self.data['memo_data'][self.id - 1]['content'] = data write(self.data) def deleteData(self, data): self.data['memo_data'].pop(data - 1) self.data['memo_num'] -= 1 write(self.data) def keyPressEvent(self, QKeyEvent): if QKeyEvent.key() == 0x01000004: self.save() # elif QKeyEvent.key() == 0x60: # print(2) def mousePressEvent(self, event): if event.button() == Qt.LeftButton: self.moveFlag = True self.positon = event.globalPos() - self.pos() def mouseMoveEvent(self, event): self.move(event.globalPos() - self.positon) can = self.pw.getTrashPos() flag = self.Collide(can, self) if flag and self.moveFlag: self.deleteMemo(True) else: self.deleteMemo(False) def mouseReleaseEvent(self, event): can = self.pw.getTrashPos() flag = self.Collide(can, self) if flag and self.moveFlag: self.deleteMemo(False) self.moveFlag = False self.hide() self.deleteData(self.id) else: self.hide() self.show() def mouseDoubleClickEvent(self, QMouseEvent): if QMouseEvent.button() == Qt.LeftButton: self.label.hide() self.doneBtn.hide() self.labelEdit.show() self.grabKeyboard() def Collide(self, widgetp, widgetc): dict1 = {} dict1['size'] = widgetp.size() dict1['pos'] = widgetp.pos() dict2 = {} dict2['size'] = widgetc.size() dict2['pos'] = widgetc.pos() pTopLeftX = dict1['pos'].x() pTopLeftY = dict1['pos'].y() pBottomRightX = dict1['pos'].x() + dict1['size'].width() pBottomRightY = dict1['pos'].y() + dict1['size'].height() childX = dict2['pos'].x() childY = dict2['pos'].y() if childX < pBottomRightX and childX > pTopLeftX and childY < pBottomRightY and childY > pTopLeftY: return True else: return False def deleteMemo(self, flag): if flag: self.pw.mainpage.delatingIcon() else: self.pw.mainpage.normalIcon() def editFinish(self): self.EditFinish.emit() def editing(self): self.Editing.emit()
def EditL(): Edit().student.last_name = input('Введите Фамиллию: ')
def EditM(): Edit().student.middle_name = input('Введите Отчество: ')
def EditG(): Edit().student.group = input('Введите Группу: ')
def DeselectS(): if StudentRegistry().getStudentsCount() != 0: Edit().student = None
from window import w from menubar import menubar from right_click_menu import rcm from edit import Edit from view import View from search import Search from theme import Themes from interpret_and_compile import Run from tools import Tools t = Themes() r = Run() e = Edit() v = View() s = Search() tl = Tools() e.edit_menu() v.view_menu() s.search_menu() t.theme_menu() tl.tools_menu() t.dark_theme() w.root.config(menu=rcm.rightclickmenu) w.root.config(menu=menubar.toolbar) w.footer_elements() if __name__ == "__main__": w.root.mainloop()
def EditF(): Edit().student.first_name = input('Введите Имя: ')