subclass

Is it possible to use a custom object instead of String inside a Tkinter Text Widget (python)?

廉价感情. 提交于 2019-12-24 18:33:32
问题 I'm trying to create a text editor that will manipulate a string like object. Ideally I would like to subclass Tkinter's Text Widget or some other Gui module to allow me to substitute this custom object instead of using strings. I understand how to create the object itself (which essentially just tags every word with meta-data), but not how to manipulate the rendered object as text while retaining its other attributes. Eg. The text editor imports a file that contains "Hello World". Upon

“no valid constructor” when serializing a subclass of Path2D.Double

ぐ巨炮叔叔 提交于 2019-12-24 18:16:05
问题 I'm trying to serialize a subclass of Path2D.Double, the serialization works, but the deserialization doesn't because of the following Exception: Exception in thread "main" java.io.InvalidClassException: CustomShape; no valid constructor at java.io.ObjectStreamClass$ExceptionInfo.newInvalidClassException(ObjectStreamClass.java:147) at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:755) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1751) at java.io

python cyclic shifting of the characters in the string

你离开我真会死。 提交于 2019-12-24 17:52:31
问题 Subclass sstr of the standard str type that implements the "<<" and ">>" methods as a cyclic shifting of the characters in the string.What trying to do is >>> s1 = sstr("abcde") >>> s1 << 0 'abcde' >>> s1 >> 0 'abcde' >>> s1 << 2 'cdeab' >>> s1 >> 2 'deabc' >>> s1 >> 5 'abcde' # my attempt: import string class sstr(str): def __new__(self, other): return str.__new__(self, other.upper()) def __ilshift__(self, other): return str.__ilshift(other) def __rshift__(self, other): return str.__rshift

Objective-C subclass and base class casting

心已入冬 提交于 2019-12-24 12:22:47
问题 I'm going to create a base class that implements very similar functions for all of the subclasses. This was answered in a different question. But what I need to know now is if/how I can cast various functions (in the base class) to return the subclass object. This is both for a given function but also a function call in it. (I'm working with CoreData by the way) As a function within the base class (this is from a class that is going to become my subclass) +(Structure *)fetchStructureByID:

custom combobox win32

こ雲淡風輕ζ 提交于 2019-12-24 12:06:37
问题 I am trying to implement an auto-suggest feature in an win32 combobox (C++). I want to achieve a behaviour that is similar to the google auto suggest function. When the user types something into the edit-control of the combobox, its listbox opens and shows all possible matches. The Problem is the default behaviour of a win32 combobox is to always select the closest match and put the complete text (selected) into the edit control when the list is opened. I need to avoid this behaviour. The

JPA discriminator column problem

坚强是说给别人听的谎言 提交于 2019-12-24 09:49:02
问题 Hallo all. I have this set of classes: @Entity @Table(name = "S_MC_CC_RAPPORTI") @Inheritance(strategy=InheritanceType.JOINED) @DiscriminatorColumn(name="COD_TIPORAPPORTO", discriminatorType=DiscriminatorType.CHAR, length=1) public abstract class Rapporto implements Serializable { private static final long serialVersionUID = -5567166522882040440L; @Id @Column(name = "COD_RAPPORTO") protected Long codiceRapporto; And this sublass: @Entity @Table(name="S_MC_CC_CCCLIENTI") @DiscriminatorValue("1

Subclassing QSqlTableModel insert new value

穿精又带淫゛_ 提交于 2019-12-24 08:25:19
问题 I want to show SQL data from a local db-File in a QML-Tableview and than would like to do some edits to the sql-database. What I managed to do after about three weeks: Showing my data in a QML-Tableview. I am not sure if I really need to subclass QSqlTableModel and I definitly would be glad if subclassing would not be neccessary at all. In my main.cpp following should create my model and directly add a record. // Create an instance of the SqlModel for accessing the data SqlDataModel *sqlModel

Nhibernate/hibernate Avoid Insert in joined table or view

為{幸葍}努か 提交于 2019-12-24 07:13:14
问题 I have to join a entity with a view to retrieve some data into properties <join table="XXVIEW" optional="true"> <key column="ID_ENT" /> <property name="Prop1" insert ="false" update ="false" /> <property name="Prop2" insert ="false" update ="false" /> <property name="Prop3" insert ="false" update ="false" /> </join> But when i try to save (insert) it fails becouse it try to insert a record in XXVIEW with ID_Ent I need to have some properties in this entity get from various calculations or

What is the initializing procedure underneath the __init__ method of python built-in list

柔情痞子 提交于 2019-12-24 06:13:55
问题 My question is will the init method of list class calling other method such as append or insert to achieve its functionality. like: class test(list): def __init__(self,values): super().__init__() def append(self, value): self.append(value + 1) I want: x = test([1,2,3]) x [2,3,4] but I got: [1,2,3] I know I can make it work by overload init itself. def __init__(self,values): super().__init__([x+1 for x in values]) Can I just overload some basic value insert method like setitem , so all the

What is the initializing procedure underneath the __init__ method of python built-in list

时光怂恿深爱的人放手 提交于 2019-12-24 06:13:28
问题 My question is will the init method of list class calling other method such as append or insert to achieve its functionality. like: class test(list): def __init__(self,values): super().__init__() def append(self, value): self.append(value + 1) I want: x = test([1,2,3]) x [2,3,4] but I got: [1,2,3] I know I can make it work by overload init itself. def __init__(self,values): super().__init__([x+1 for x in values]) Can I just overload some basic value insert method like setitem , so all the