小编ryv*_*ron的帖子

如何将命令从Python龟图形发送到EV3乐高积木?

编辑T KINTER:

IDE是Visual Studio Code

跟踪调用打印在脚本下方

TkinterTest.py

#!/usr/bin/env python3

from tkinter import *
from tkinter import ttk
import Ev3_Motor

ev3 = Ev3_Motor.Ev3_Motor()

def calculate(*args):
    ev3.TestFunction("SUCCESSS YAHOOOOOO")
    print("command to robot >>>>")

root = Tk()
root.title("TEST TKINTER")

mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)

ttk.Button(mainframe, text="TEST BUTTON", command=calculate).grid(column=3, row=3, sticky=W)

#ttk.Label(mainframe, text="feet").grid(column=3, row=1, sticky=W)
for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)

root.bind('<Return>', calculate)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)

Ev3_Motor.py

#!/usr/bin/env python3
from ev3dev.ev3 import *
import os …
Run Code Online (Sandbox Code Playgroud)

python robotics turtle-graphics python-3.x

9
推荐指数
1
解决办法
329
查看次数

如何在.proto文件中处理带协议缓冲区的泛型类型对象?

我花了一些时间寻找处理通用对象的替代方法,我看到类似于我的问题,但不是我想的那么具体?协议缓冲区有多种标量类型我可以使用,但它们大多是原始的.我希望我的消息灵活,并且能够拥有某种列表的字段.

假设我的.proto文件看起来像这样:

   message SomeMessage
   {
      string datetime = 1;
      message inputData // This would be a list
      {
         repeated Object object = 1;
      }
      message Object 
      {
          ? // this need to be of a generic type - This is my question
          // My work around - Using extentions with some Object
          //List all primitive scalar types as optional and create an extension 100 to    max;
      }
      message someObject //some random entity - for example, employee/company etc.
      {  
          optional string …
Run Code Online (Sandbox Code Playgroud)

object generic-list protocol-buffers

6
推荐指数
4
解决办法
1万
查看次数

使用Git Gui Windows - 如何保存用户凭据 - 用户名和密码

我知道之前已经问过这个问题,我一直在看这个链接:

https://www.kernel.org/pub/software/scm/git/docs/git-credential-store.html

我真的很擅长使用Git Gui Application for Windows和Git Hub.

我通过Git Hub网站以https://github.com/projectname.git格式输入存储库的URL来"获取"现有存储库

为了推动它,我将粘贴文件复制到我的本地git目录中,然后在Git Gui中点击f5并提交/推送到原点.

但是每次我想要推送一些东西 - 它会询问我的用户名和密码.该指南说使用给定格式的用户名和密码创建名为.git-credentials的文本文件:

https://开头的用户:pass@example.com

题:

如何将.git-credentials文件的使用链接到我的Git Gui应用程序?...我使用的是DOS吗?或者从某个地方来一些Git Shell?...

任何帮助将不胜感激...

credentials github git-gui

6
推荐指数
1
解决办法
2万
查看次数

Android - 简单的XML框架.@Convert干扰@Attribute - 如何解决这个问题?

我正在努力捕获标签中包含的元素的顺序.这是所有代码:

League.java:

@Root
@Convert(value = LeagueConverter.class)
public class League 
{
    @Attribute
    private String name;

    @Element(name="headlines", required = false)
    private Headlines headlines;

    @Element(name="scores", required = false)
    private Scores scores;

    @Element(name="standings", required = false)
    private Standing standings;

    @Element(name="statistics", required = false)
    private LeagueStatistics statistics;

    public List<String> order = new ArrayList<String>();

        // get methods for all variables
}
Run Code Online (Sandbox Code Playgroud)

LeagueConverter.java:

public class LeagueConverter implements Converter<League>
{
       @Override
       public League read(InputNode node) throws Exception
       {
               League league = new League();
               InputNode next = node.getNext();
               while( …
Run Code Online (Sandbox Code Playgroud)

android converter xml-parsing simple-framework

2
推荐指数
1
解决办法
1811
查看次数

使用Bitmap Factory选项支持多个屏幕?

编辑一个:

根据约瑟夫的回答做出的改变:

在bytesToDrawable(byte [] imageBytes)中:

更改了以下内容:使用BitmapDrawable(资源res,位图位图)而不是BitmapDrawable(位图位图):

return new BitmapDrawable(ApplicationConstants.ref_currentActivity.getResources(),BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length, options));
Run Code Online (Sandbox Code Playgroud)

这是这种变化的结果:略有不同的问题:

在此输入图像描述

题:

如果我正在使用新的构造函数来绘制位图并将图像缩放到所需的目标密度,那么我还需要使用我的calculateSampleSize方法吗?


原始问题:

嗨朋友们,

我的应用程序是基于模块的,因此特定于该模块的图像仅从包含它们的jar(模块)加载,而不是从主应用程序加载.

每个模块都有自己的ModularImageLoader - 它基本上允许我根据jar中找到的图像名称来获取Drawables.

构造函数接收zipFile(模块A)和文件名列表(zip中以".png"结尾的任何文件).

研究实施:

我使用了以下内容:有效加载位图链接到开发人员页面

最初我是为每个密度创建大小的图像,但现在我只有一组大小为96x96的图像图标.

如果屏幕密度小于xhdpi,我会加载96x96图像的较小采样大小 - 36x36(对于ldpi),48x48(对于mdpi),72x72(对于hdpi).否则我只返回96x96图像.(查看方法calculateSampleSize()和bytesToDrawable())

我认为用代码更容易理解这个概念:所以这里是ModularImageLoader

码:

public class ModularImageLoader
{
    public static HashMap<String, Drawable> moduleImages = new HashMap<String, Drawable>();
    public static int reqHeight = 0;
    public static int reqWidth = 0;
    public ModularImageLoader(ZipFile zip, ArrayList<String> fileNames)
    {
         float sdpi = ApplicationConstants.ref_currentActivity.getResources().getDisplayMetrics().density;
         if(sdpi == 0.75)
         {
            reqHeight = 36;
            reqWidth = 36;
         }
         else if(sdpi == …
Run Code Online (Sandbox Code Playgroud)

android module screen android-emulator bitmapfactory

1
推荐指数
1
解决办法
2244
查看次数