Vampire_BY 3 #286996 Posted August 10, 2015 (edited) Может кто показать как вывести на форму значение взятые c api через скрипт Python? Edited August 10, 2015 by Deno Quote Share this post Link to post Short link Share on other sites
SV43 0 #287113 Posted August 11, 2015 (edited) Может кто показать как вывести на форму значение взятые c api через скрипт Python? На несколько постов выше на ваш вопрос ответ http://www.koreanrandom.com/forum/topic/25477-как-создать-формуокно-в-ангаре/?p=285620 http://www.koreanrandom.com/forum/topic/25477-как-создать-формуокно-в-ангаре/?p=285633 Edited August 11, 2015 by SV43 Quote Share this post Link to post Short link Share on other sites
Vampire_BY 3 #287133 Posted August 11, 2015 Как определить this.startF(); и this.ontextFieldTest ? package { import flash.events.*; import flash.display.*; import scaleform.clik.core.UIComponent; import net.wg.infrastructure.base.AbstractWindowView; import net.wg.gui.components.controls.SoundButton; import flash.text.TextField; public class TestWindow extends AbstractWindowView { public var testF:Function = null; public var textFieldTest:TextField; public function as_setText(param:String):void { this.textFieldTest.htmlText = param; } public function TestWindow() { super(); } override protected function configUI() : void { super.configUI(); this.textFieldTest = new TextField(); this.textFieldTest.width = 590; this.textFieldTest.height = 360; this.textFieldTest.x = 5; this.textFieldTest.y = 0; this.textFieldTest.multiline = true; this.textFieldTest.selectable = false; this.startF(); this.addChild(this.textFieldTest); this.textFieldTest.addEventListener(MouseEvent.CLICK, this.ontextFieldTest); } override protected function onPopulate() : void { super.onPopulate(); this.width = 600; this.height = 400; this.window.title = "Test Window"; } override protected function onDispose() : void { super.onDispose(); } } } Ошибки: Error: Call to a possibly undefined method startF through a reference with static type TestWindow. Error: Access of possibly undefined property ontextFieldTest through a reference with static type TestWindow. Quote Share this post Link to post Short link Share on other sites
SkepticalFox 1,445 #287134 Posted August 11, 2015 (edited) del Edited June 19, 2016 by ShadowHunterRUS 1 Quote Share this post Link to post Short link Share on other sites
Vampire_BY 3 #287136 Posted August 11, 2015 (edited) Снова где то накосячил. Все скомпилировалось но сообщения не вывелось + крестик съехал))) 'Скрин' 'TestWindows.py' from gui.Scaleform.framework import g_entitiesFactories, ViewSettings from gui.Scaleform.framework import ViewTypes, ScopeTemplates from gui.Scaleform.daapi.view.meta.WindowViewMeta import * from gui.Scaleform.daapi import LobbySubView from gui.WindowsManager import g_windowsManager from gui.shared.utils.key_mapping import getBigworldNameFromKey from gui.Scaleform.framework.entities.View import View class TestWindow(LobbySubView, WindowViewMeta): def __init__(self): View.__init__(self) def _populate(self): View._populate(self) def onWindowClose(self): self.destroy() def onTryClosing(self): return True def as_setTextS(self): if self._isDAAPIInited(): return self.flashObject.as_setText('<font color="#FFFFFF">Hello World!</font>') def startF(self): self.as_setTextS() _alias = 'TestWindow' _url = 'TestWindow.swf' _type = ViewTypes.WINDOW _event = None _scope = ScopeTemplates.DEFAULT_SCOPE _settings = ViewSettings(_alias, TestWindow, _url, _type, _event, _scope) g_entitiesFactories.addSettings(_settings) def onhandleKeyEvent(event): key = getBigworldNameFromKey(event.key) if key == 'KEY_F10': g_windowsManager.window.loadView('TestWindow', 'TestWindow') return None from gui import InputHandler InputHandler.g_instance.onKeyDown += onhandleKeyEvent 'TestWindows.as' package { import flash.events.*; import flash.display.*; import scaleform.clik.core.UIComponent; import net.wg.infrastructure.base.AbstractWindowView; import net.wg.gui.components.controls.SoundButton; import flash.text.TextField; public class TestWindow extends AbstractWindowView { public var textFieldTest:TextField; private var startF:Function; public function as_setText(param:String):void { this.textFieldTest.htmlText = param; } public function TestWindow() { super(); } override protected function configUI() : void { super.configUI(); this.textFieldTest = new TextField(); this.textFieldTest.width = 590; this.textFieldTest.height = 360; this.textFieldTest.x = 5; this.textFieldTest.y = 0; this.textFieldTest.multiline = true; this.textFieldTest.selectable = false; this.startF(); this.addChild(this.textFieldTest); } override protected function onPopulate() : void { super.onPopulate(); this.width = 600; this.height = 400; this.window.title = "Test Window"; } override protected function onDispose() : void { super.onDispose(); } } } Edited August 11, 2015 by Mr.Deno Quote Share this post Link to post Short link Share on other sites
SkepticalFox 1,445 #287137 Posted August 11, 2015 (edited) del Edited June 19, 2016 by ShadowHunterRUS Quote Share this post Link to post Short link Share on other sites
Vampire_BY 3 #287140 Posted August 11, 2015 (edited) ,Повнимательнее прочитайте мое сообщение выше Нет тот код от питона выложил и еще тот стер ((( щя переделаю отпишусь Выложил код, там наверное путаница с именами функций вот эта часть меня смущает: def testF(self, param1): print param1 Этот кусок удалил так как он по ходу не нужен хз где его я взял Смещения крестика происходит из за this.startF(); если не ошибаюсь эта функция должна выводит текст 'Смещения крестика' p.s Я вообще уже перестал понимать что к чему и как вывести текст. Edited August 11, 2015 by Mr.Deno Quote Share this post Link to post Short link Share on other sites
SV_Kirov 1 #287166 Posted August 11, 2015 (edited) 'TestWindows.as' package { import flash.events.*; import flash.display.*; import scaleform.clik.core.UIComponent; import net.wg.infrastructure.base.AbstractWindowView; import net.wg.gui.components.controls.ResizableScrollPane; import net.wg.gui.components.controls.ScrollPane; import net.wg.gui.components.controls.SoundButton; import flash.text.TextField; import net.wg.gui.components.advanced.ContentTabBar; import scaleform.clik.core.UIComponent; public class TestWindow extends AbstractWindowView { public var textFieldTest:TextField; public var testScrollPane:ScrollPane; public var ContentTab:ContentTabBar; public var startF:Function; public function as_setText(param:String):void { this.textFieldTest.htmlText = param; } public function TestWindow() { super(); } override protected function configUI() : void { super.configUI(); this.textFieldTest = new TextField(); this.textFieldTest.width = 500; this.textFieldTest.height = 550; this.textFieldTest.x = 5; this.textFieldTest.y = 0; this.textFieldTest.multiline = true; this.textFieldTest.selectable = false; this.startF(); this.addChild(this.textFieldTest); this.textFieldTest.addEventListener(MouseEvent.CLICK, this.ontextFieldTest); } override protected function onPopulate() : void { super.onPopulate(); this.width = 600; this.height = 400; this.window.title = "Test Window"; } override protected function onDispose() : void { super.onDispose(); } private function ontextFieldTest(event:MouseEvent) : void { } } } 'TestWindows.ry' from gui.Scaleform.framework import g_entitiesFactories, ViewSettings from gui.Scaleform.framework import ViewTypes, ScopeTemplates from gui.Scaleform.daapi.view.meta.WindowViewMeta import * from gui.Scaleform.daapi import LobbySubView from gui.WindowsManager import g_windowsManager from gui.shared.utils.key_mapping import getBigworldNameFromKey from gui.Scaleform.framework.entities.View import View class TestWindow(LobbySubView, WindowViewMeta): def __init__(self): View.__init__(self) def _populate(self): View._populate(self) def as_setTextS(self): if self._isDAAPIInited(): text = urlopen('Hello World').read() def onWindowClose(self): self.destroy() def onTryClosing(self): return True def startF(self): self.as_setTextS() _alias = 'TestWindow' _url = 'TestWindow.swf' _type = ViewTypes.WINDOW _event = None _scope = ScopeTemplates.DEFAULT_SCOPE _settings = ViewSettings(_alias, TestWindow, _url, _type, _event, _scope) g_entitiesFactories.addSettings(_settings) def onhandleKeyEvent(event): key = getBigworldNameFromKey(event.key) if key == 'KEY_F10': g_windowsManager.window.loadView('TestWindow', 'TestWindow') return None from gui import InputHandler InputHandler.g_instance.onKeyDown += onhandleKeyEvent Mr.Deno, У тебя где то косяк в swf Edited August 11, 2015 by SV_Kirov 1 Quote Share this post Link to post Short link Share on other sites
Vampire_BY 3 #287167 Posted August 11, 2015 (edited) TestWindows.as package { import flash.events.*; import flash.display.*; import scaleform.clik.core.UIComponent; import net.wg.infrastructure.base.AbstractWindowView; import net.wg.gui.components.controls.ResizableScrollPane; import net.wg.gui.components.controls.ScrollPane; import net.wg.gui.components.controls.SoundButton; import flash.text.TextField; import net.wg.gui.components.advanced.ContentTabBar; import scaleform.clik.core.UIComponent; public class TestWindow extends AbstractWindowView { public var textFieldTest:TextField; public var testScrollPane:ScrollPane; public var ContentTab:ContentTabBar; public var startF:Function; public function as_setText(param:String):void { this.textFieldTest.htmlText = param; } public function TestWindow() { super(); } override protected function configUI() : void { super.configUI(); this.textFieldTest = new TextField(); this.textFieldTest.width = 500; this.textFieldTest.height = 550; this.textFieldTest.x = 5; this.textFieldTest.y = 0; this.textFieldTest.multiline = true; this.textFieldTest.selectable = false; this.startF(); this.addChild(this.textFieldTest); this.textFieldTest.addEventListener(MouseEvent.CLICK, this.ontextFieldTest); } override protected function onPopulate() : void { super.onPopulate(); this.width = 600; this.height = 400; this.window.title = "Test Window"; } override protected function onDispose() : void { super.onDispose(); } private function ontextFieldTest(event:MouseEvent) : void { } } } TestWindows.ry from gui.Scaleform.framework import g_entitiesFactories, ViewSettings from gui.Scaleform.framework import ViewTypes, ScopeTemplates from gui.Scaleform.daapi.view.meta.WindowViewMeta import * from gui.Scaleform.daapi import LobbySubView from gui.WindowsManager import g_windowsManager from gui.shared.utils.key_mapping import getBigworldNameFromKey from gui.Scaleform.framework.entities.View import View class TestWindow(LobbySubView, WindowViewMeta): def __init__(self): View.__init__(self) def _populate(self): View._populate(self) def as_setTextS(self): if self._isDAAPIInited(): text = urlopen('Hello World').read() def onWindowClose(self): self.destroy() def onTryClosing(self): return True def startF(self): self.as_setTextS() _alias = 'TestWindow' _url = 'TestWindow.swf' _type = ViewTypes.WINDOW _event = None _scope = ScopeTemplates.DEFAULT_SCOPE _settings = ViewSettings(_alias, TestWindow, _url, _type, _event, _scope) g_entitiesFactories.addSettings(_settings) def onhandleKeyEvent(event): key = getBigworldNameFromKey(event.key) if key == 'KEY_F10': g_windowsManager.window.loadView('TestWindow', 'TestWindow') return None from gui import InputHandler InputHandler.g_instance.onKeyDown += onhandleKeyEvent Mr.Deno, У тебя где то косяк в swf Все отображает спасибо Только text = urlopen('Hello World').read() заменил на return self.flashObject.as_setText('<font color="#FFFFFF">Hello World</font>') Edited August 11, 2015 by Mr.Deno Quote Share this post Link to post Short link Share on other sites
SV_Kirov 1 #287180 Posted August 11, 2015 Все отображает спасибо Только text = urlopen('Hello World').read() заменил на return self.flashObject.as_setText('<font color="#FFFFFF">Hello World</font>') Точно, второй раз на одни и теже грабли. Думаю и исходнике было всё норм Quote Share this post Link to post Short link Share on other sites
Vampire_BY 3 #287189 Posted August 11, 2015 (edited) Как лучше сделать что бы можно было расположить нужные значения спаренные в нужной точки формы Пример: #обрабатывает данные полученные через API WG rsp = json.loads(req.text) Данные в таком виде {u'status': u'ok', u'meta': {u'count': 5}, u'data': [{u'nickname': u'Vampire00', u'account_id': 50805}, {u'nickname': u'vampire00000', u'account_id': 35007367}, {u'nickname': u'Vampire00022202', u'account_id': 23297229}, {u'nickname': u'Vampire0005', u'account_id': 3179509}, {u'nickname': u'Vampire0007', u'account_id': 2146788}]} Выводим только nickname и id игроков for i in rsp.get('data'): print 'name:', i.get('nickname'), ' id:', i.get('account_id') test_print() но если подставить return self.flashObject.as_setText('<font color="#FFFFFF">'+test_print()+'</font>') ему так не нравиться. но и даже если бы сработало было бы коряво и не красиво. А я хочу что бы получилось примерно так: p.s Может есть пример подобного или подскажите что почитать буду благодарен Edited August 11, 2015 by Mr.Deno Quote Share this post Link to post Short link Share on other sites
SV_Kirov 1 #287192 Posted August 11, 2015 как вариант можно попробовать html тегами, например табличку заюзать <table> <tr> <td>Name</td> <td>id</td> </tr> <tr> <td>Name2</td> <td>id2</td> </tr> </table> как то так Quote Share this post Link to post Short link Share on other sites
SkepticalFox 1,445 #287193 Posted August 11, 2015 (edited) del Edited February 10, 2016 by ShadowHunterRUS Quote Share this post Link to post Short link Share on other sites
Vampire_BY 3 #287195 Posted August 11, 2015 (edited) вместо print используй return Пробовал но тогда он выводит первую запись и все Вывести все записи у меня получилось только записать сначала в файл а потом вывести файл запись данных: def test_print(): f = open('c:\\text.txt', 'w') for i in rsp.get('data'): f.write("%s\n" % i.get('nickname')) msg = open('c:\\text.txt','r').read() вывод данных: SystemMessages.pushMessage(msg, type) Но так криво и мне не нравиться Edited August 11, 2015 by Mr.Deno Quote Share this post Link to post Short link Share on other sites
SkepticalFox 1,445 #287196 Posted August 11, 2015 (edited) del Edited June 19, 2016 by ShadowHunterRUS 1 Quote Share this post Link to post Short link Share on other sites
Vampire_BY 3 #287201 Posted August 11, 2015 (edited) конкатенируй строки def test_print(): str1 = "" for i in rsp.get('data'): str1 += "Nickname: %s Id: %s\n" % (i.get('nickname') , i.get('account_id')) return str1 В таком случаи проблемы с вывод решились спасибо (надо почитать про этот метод). А вот что на счет разметки, пытаться использовать html? Edited August 11, 2015 by Mr.Deno Quote Share this post Link to post Short link Share on other sites
SV_Kirov 1 #287203 Posted August 11, 2015 Читай выше мой пост. Вроде тег <table></table> работает Quote Share this post Link to post Short link Share on other sites
SkepticalFox 1,445 #287204 Posted August 11, 2015 (edited) del Edited June 19, 2016 by ShadowHunterRUS Quote Share this post Link to post Short link Share on other sites
Vampire_BY 3 #287205 Posted August 11, 2015 справочник по html найди в интернете. как варианнт обновил сообщение выше Всем спасибо за помощь буду пытаться дальше. Quote Share this post Link to post Short link Share on other sites
SkepticalFox 1,445 #287206 Posted August 11, 2015 (edited) del Edited February 10, 2016 by ShadowHunterRUS 1 Quote Share this post Link to post Short link Share on other sites