class

Python + Pygame + PygButton detecting

感情迁移 提交于 2019-12-25 04:25:15
问题 I'm using Python 3.3 with Pygame and PygButton (low rep don't allow me more than two links) My files at the moment are [ int.py http://pastebin.com/sDRhieCG ] and [ scene.py http://pastebin.com/Y2Mgsgmr ]. The idea is making a mainloop in int.py the smaller as possible. The code has a commented-out example of the start_screen buttons at the mainloop. It works, but with every new screen the mainloop would be bloated. So I created a Scene class to apply background, texts and buttons. It works,

Difference between Class reference and Interface reference

六月ゝ 毕业季﹏ 提交于 2019-12-25 04:22:36
问题 My code is: class Sample implements interf { public void intmethod(){ //some code.... } } public interface interf{ public void intmethod() } My question is what is difference between the following two statements Sample sam = new Sample(); interf int = new Sample(); 回答1: Let's say you have: class Sample implements interf { public void intmethod(){ //some code.... } public void sampleMethod() { // code only relevant to Sample objects} } class Sample2 implements interf { public void intmethod(){

implementing add and iadd for custom class in python?

爷,独闯天下 提交于 2019-12-25 04:22:25
问题 I am writing a Queue class that wraps list for most of its operations. But I do not sublcass from list , since I do not want to provide all the list API's . I have my code pasted below. The add method seems to work fine, but iadd seems to go wrong, it is printing none. Here is the code: import copy from iterator import Iterator class Abstractstruc(object): def __init__(self): assert False def __str__(self): return "<%s: %s>" %(self.__class__.__name__,self.container) class Queue(Abstractstruc

js实现翻牌效果

别来无恙 提交于 2019-12-25 04:21:56
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover"> <title>翻牌抽奖</title> <style> body {background: #E7244B;} *{margin:0;padding:0}a img{border:0} a{text-decoration:none;-webkit-tap-highlight-color:rgba(0,0,0,0);text-align: center;} .top {width: 100%;} .weui-grid {padding: 0;} .weui-grid:before {border: 0;} .weui-grid:after {border: 0;} .weui-grids:before {border: 0;} .img {width: 90%;margin-top: 1vw;height: 33.9vw} .info {display: none;margin-top: 1vw;width: 0;height: 33.9vw;} .shelter {opacity: 0.5;filter: alpha

C# adding control from another class

风格不统一 提交于 2019-12-25 04:14:41
问题 I want to add form controls dynamically to my form from another class which inherits the form class. Everything works fine but it does not add the controls at run time. Here is my sample code: namespace Namespace1 { public partial class Form1 : Form { ..... } ....... }// end of Namespace1 namespace Namespace2 { public class1:Form1 { public Button button = new Button(); public void method1() { button1.Name="button1"; //flowlayoutcontrol1 is a public control on Form1 flowlayoutcontrol1.Controls

as3 accessing Children from dynamicly added moiveclip

拜拜、爱过 提交于 2019-12-25 04:09:28
问题 I am adding moiveClips and putting their position accordingly. I am placing all the dynamically added clips in one new movie clip and then centering that on stage. As a test, I see I can control the alpha in the main container but I can not access the children. How can I assess each flagButton separately? There would be several in this loop example below. var flagButton:MovieClip; var flagArray:Array = new Array; var flagDisplayButtons:MovieClip = new MovieClip(); function displayFlagButtons(

When using the 'Class' datatype, how can I specify the type so I only accept subclass of a specific class?

孤人 提交于 2019-12-25 04:06:24
问题 I've got a method that accepts a parameter of type Class , and I want to only accept classes that extend SuperClass . Right now, all I can figure out to do is this, which does a run-time check on an instance: public function careless(SomeClass:Class):void { var instance:SomeClass = new SomeClass(); if (instance as SuperClass) { // great, i guess } else { // damn, wish i'd have known this at compile time } } Is there any way to do something like this, so I can be assured that a Class instance

When using the 'Class' datatype, how can I specify the type so I only accept subclass of a specific class?

烂漫一生 提交于 2019-12-25 04:06:18
问题 I've got a method that accepts a parameter of type Class , and I want to only accept classes that extend SuperClass . Right now, all I can figure out to do is this, which does a run-time check on an instance: public function careless(SomeClass:Class):void { var instance:SomeClass = new SomeClass(); if (instance as SuperClass) { // great, i guess } else { // damn, wish i'd have known this at compile time } } Is there any way to do something like this, so I can be assured that a Class instance

Looping over class variable's attributes in python

陌路散爱 提交于 2019-12-25 03:54:31
问题 Building on this question looping over all member variables of a class in python Regarding how to iterate over a class' attributes / non functions. I want to loop over the class variable values and store in a list. class Baz: a = 'foo' b = 'bar' c = 'foobar' d = 'fubar' e = 'fubaz' def __init__(self): members = [attr for attr in dir(self) if not attr.startswith("__")] print members baz = Baz() Will return ['a', 'b', 'c', 'd', 'e'] I would like the class attribute values in the list. 回答1: Use

Looping over class variable's attributes in python

六眼飞鱼酱① 提交于 2019-12-25 03:54:01
问题 Building on this question looping over all member variables of a class in python Regarding how to iterate over a class' attributes / non functions. I want to loop over the class variable values and store in a list. class Baz: a = 'foo' b = 'bar' c = 'foobar' d = 'fubar' e = 'fubaz' def __init__(self): members = [attr for attr in dir(self) if not attr.startswith("__")] print members baz = Baz() Will return ['a', 'b', 'c', 'd', 'e'] I would like the class attribute values in the list. 回答1: Use